Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When SQL Server bcps into an empty table with an index what does it do internally?

If I have an empty table with an index and I do a bcp, does SQL Server (internally) drop/disable the index, load the data and then re-apply/enable/build the index?

like image 508
Mike Q Avatar asked Dec 22 '22 22:12

Mike Q


1 Answers

No, the indexes are maintained throughout the operation. In fact, Microsoft says you can improve bcp performance by using the -h ORDER hint to sort the data according to your clustered index. See the bcp Utility documentation for details. However, as stated here, for the fastest import possible you should take the following steps:

· The "select into/bulkcopy" database option must be set to "true".

· The target table should not have any indexes. [emphasis added]

· The target table must not be published for replication.

· Use the TABLOCK to lock the target table.

like image 151
Joe Stefanelli Avatar answered May 03 '23 06:05

Joe Stefanelli