Best possible ways to disable index before insert operation and enable back Index after insert

Jay Nani picture Jay Nani · Nov 11, 2016 · Viewed 7.2k times · Source

I'm planning to create a Non-clustered columnstore index on SQL Server 2014.

But non clustered column store index is read-only and cannot perform DML operations, we need to disable before insert and enable back after insert.

What are the best possible ways to perform this task?

Answer

Derrick Moeller picture Derrick Moeller · Nov 11, 2016

Simply disable the index and perform a rebuild. https://msdn.microsoft.com/en-us/library/dn589806(v=sql.120).aspx

ALTER INDEX mycolumnstoreindex ON mytable DISABLE;  
-- update mytable --  
ALTER INDEX mycolumnstoreindex on mytable REBUILD