Disabling indexes for a SqlBulkCopy errors out

.net indexing sql sqlbulkcopy

Question

I'm trying to improve the peformance of a call to SqlBulkCopy.WriteToServer(Datatable).

One of the suggestions I've seen is to temporarily disable the indexes on the table before the call to WriteToServer, and then enable the indexes afterwords.

I disable the table with this statement, ALTER INDEX 'IndexName' ON 'TableName' DISABLE

The problem I run into, is after I disable to the indexes and try to perform the write an error occurs with the statement, The query processor is unable to produce a plan because the index 'IndexName' on table or view 'TableName' is disabled.

Any ideas on how I can avoid this error or improve the write spends by some other means?

Accepted Answer

You disabled the cluster index, instead of just non-cluster indices. Once Cluster index is disabled, you can not perform DML on table.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why