This article is half-done without your Comment! *** Please share your thoughts via Comment ***
This post is for SQL Server developers who are in intermediate level. Why people are asking this question because when you are performing any optimization related activity at that time, you need to test lots of indexes.
In that case, I have found many of developers who are dropping and creating indexes again and again for their testing purpose.
If you are good T-SQL Developer, you must know that you can also enable and disable the indexes. So I am sharing this interview question…
How to disable the index?
1 2 |
ALTER INDEX index_name ON table_name DISABLE GO |
How to enable the index?
1 2 |
ALTER INDEX index_name ON table_name REBUILD GO |
How to check the status?
1 2 3 4 5 6 7 8 |
SELECT name AS IndexName ,type_desc AS IndexType , CASE IS_DISABLED WHEN 0 THEN 'Enabled' ELSE 'Disabled' END AS IndexStatus FROM SYS.INDEXES |
Leave a Reply