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
383 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now