Ashley Grenon
Ashley Grenon

Reputation: 9565

Disabling indexes for a SqlBulkCopy errors out

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?

Upvotes: 4

Views: 1009

Answers (1)

ljh
ljh

Reputation: 2594

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

Upvotes: 3

Related Questions