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
 General SQL Server Forums
 New to SQL Server Programming
 sp_dropindex

Author  Topic 

gregoryagu
Yak Posting Veteran

80 Posts

Posted - 2008-07-31 : 15:10:40
I am forever writing:

IF EXISTS (SELECT * FROM dbo.sysindexes WHERE id = OBJECT_ID(N'[dbo].[Objects]')
AND name = N'IDX_Objects_name_creatorid')
DROP INDEX [dbo].[Objects].[IDX_Objects_name_creatorid]

Would it not be better and easier to write a stored procedure that just takes the tablename and indexname and drops it if it exists, thereby saving me from such drudgery?

Something like

sp_DropIndex('Objects', 'IDX_Objects_name_creatorid')

Greg

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-07-31 : 15:32:25
Sure, feel free to post your script in the "Script Library" forum when it has been completed so that other people can enjoy.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

gregoryagu
Yak Posting Veteran

80 Posts

Posted - 2008-08-01 : 11:18:27
I have put several scripts over there that I just wrote - Hopefully they don't have too many bugs...

Greg
Go to Top of Page
   

- Advertisement -