Disabling indexes for a SqlBulkCopy errors out

.net, indexing, sql, sqlbulkcopy

Solution

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

Problem

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?

Original source