Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop index..? 1

Status
Not open for further replies.

kenjoswe

Technical User
Joined
Sep 19, 2000
Messages
327
Location
SE
Hi all,

How can I drop an index if it exists and create an index if it doesn't exists?

/Kent J.
 

You can do the following.

USE pubs
IF EXISTS (SELECT name FROM sysindexes
WHERE name = 'au_id_ind')
BEGIN
DROP INDEX authors.au_id_ind
END
GO

CREATE INDEX au_id_ind
ON authors (au_id)

See SQL BOL "CREATE INDEX" and "DROP INDEX" topics for more options and details. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
OK! Thanks!

/Kent J.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top