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
 SQL Server Development (2000)
 Check if index exists?

Author  Topic 

BigBadBurrow
Starting Member

4 Posts

Posted - 2007-07-05 : 07:44:09
How do I check if an index exists in SQL Server?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-07-05 : 07:50:14
Check for index name in sysindexes table.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-07-05 : 11:12:36

if indexproperty(object_id('MyTableName'),'MyIndexName','IndexID') is not null
print 'Index Exists'
else
print 'Index Does not Exist'


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -