Hi... I have a table which I want to programmatically create a clustered index using the following statement:
ALTER TABLE tBooks ADD CONSTRAINT PK_BookNbr PRIMARY KEY CLUSTERED (BookNbr)
which works just fine. Now, I want to check if the index already exists before I issue the command again (from within a C# program). I was using the following command:
SELECT name FROM sysindexes WHERE name = 'PK_BookNbr'
but it doesn't find the existing index and tries to re-create it.
What is the proper syntax to see if the index already exists in a table?
Thanks for your help in advance.