May 29, 2007 at 8:49 am
hello,
sorry but i'm a complete newbie at sql so forgive my complete ignorance...
I want to create a stored procedure and drop an index based on an input parameter for the index name, however the command 'DROP INDEX @indname' doesn't want to work....
whats the correct declaration for @indname
any help much appreciated.
Andrew
May 29, 2007 at 8:57 am
Andrew
Your first reference should always be Books Online. You get a much quicker answer than you do here!
DROP INDEX 'tablename.indexname'
John
May 29, 2007 at 9:04 am
There are no parameters that can be used for objects (TABLE, INDEX, VIEW - whatever), you always have to name the object directly (can't use a parameter that holds the name). That's true not only for CREATE and DROP, but also for SELECT - you can't use select * from @table.
Generally, you should not need it. If you are designing something, try to avoid the need for such calls; if you are using a DB that is designed in a way that requires it, consider dynamic SQL as a workaround.
I suggest to read this article first : The Curse and Blessings of Dynamic SQL
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply