Solved

What is the fastest way to remove the index on Column A and C but keep the index on column B

Posted on 2011-02-24
4
386 Views
Last Modified: 2012-05-11
I have a table with columns A, B, and C, where a unique clustered index exists on column A, a unique non-clustered index exists on Column B, and a non-unique non-clustered index exists on column C.  Assuming there are 100 million records in this table, what is the fastest way to remove the index on Column A and C but keep the index on column B?
0
Comment
Question by:tesla764
  • 2
4 Comments
 
LVL 26

Expert Comment

by:tigin44
ID: 34971382
use
drop index

this will drop indexes one by one...
0
 
LVL 26

Expert Comment

by:tigin44
ID: 34971421
an example syntax for drop index is

IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tableName]') AND name = N'indexName')
DROP INDEX [ndexName] ON [dbo].[tableName] WITH ( ONLINE = OFF )
GO
0
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 34971489
If you have an index on columns A,B,C and you want it only on column B then do following:

Add new index with ONLINE = ON on column B so you don't lock the table; you may want to look at SORT_IN_TEMPDB = ON and MAXDOP = 1 if you have a huge table indeed and is used on line.

update statistics table_name;
exec sp_recompile table_name;

drop index  idx_columns_a_b_c  on table_name;

update statistics table_name;
exec sp_recompile table_name;
0
 

Author Closing Comment

by:tesla764
ID: 34971846
Thanks, that worked.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question