Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Remove a clustered index knowing only table name??

Author  Topic 

ratinakage
Starting Member

16 Posts

Posted - 2006-03-07 : 03:49:40
Hey there guys.

I have a problem with creating a clustered index when there is already one defined for the table.

CREATE CLUSTERED INDEX ix_post_ds_terminals_bbl_1 ON post_ds_terminals_bbl
(
calendar_date,
terminal_id
)
GO

I get the following error:

Server: Msg 1902, Level 16, State 3, Line 5
Cannot create more than one clustered index on table 'post_ds_terminals_bbl'. Drop the existing clustered index 'ix_post_ds_terminals_bbl_1' before creating another.

My question is how can I find out if any clustered indexes exist for a specific table so as to delete them? The sysindexes table has the names of the indexes but not thier associated table names. Or am I missing something?

any help would be great.

Thanks

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-03-07 : 03:53:44
in EM, right click table and choose All Tasks-->manage indexes

--------------------
keeping it simple...
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-03-07 : 03:58:14
Search for SysIndexes on Book online..

Sucess Comes to those who Believe in Beauty of their Dream..
Go to Top of Page

ratinakage
Starting Member

16 Posts

Posted - 2006-03-07 : 04:20:59
quote:
Originally posted by jen

in EM, right click table and choose All Tasks-->manage indexes




Thanks, but that doesnt really help. I need a way of putting it into an SQL script. That script must check whether there exists a clustered index belonging to a certain table. If so, it must delete that clustered index before inserting the new one (or the new insert will fail)

Any more ideas?

-----
peace
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-03-07 : 04:28:39
if exists(select query here...)
drop the index here

create the index here

--select query is join for sysobjects and sysindexes, explore, but I believe scripts have been created for this... try to search for the topic [sorry not much help there]

--oh fast one, generate the script for the indexes on the table, you'll get the tsql from there

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -