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
 Transact-SQL (2000)
 drop index within stored procedure

Author  Topic 

Osme
Starting Member

2 Posts

Posted - 2007-04-17 : 05:32:12
hi,

total newbie here so i'll apologise up front for my total incompetance....

i want to create a simple stored procedure which will accept an index name as an input parameter and then drop that index. sounds fairly straightforward to me but can seem to get the syntax right -

CREATE PROC <procname> @indexname varchar(50)
AS
DROP INDEX @indexname


any help much appreciated,

Osme.





bpgupta
Yak Posting Veteran

75 Posts

Posted - 2007-04-17 : 05:38:38
you can test your self in test database
Go to Top of Page

Osme
Starting Member

2 Posts

Posted - 2007-04-17 : 05:47:51
have done. syntax fails
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-17 : 07:20:13
Why do you need stored procedure?
Drop them when needed. Dont pass them as parameters
You can try

EXEC('DROP INDEX '+@indexname)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

bpgupta
Yak Posting Veteran

75 Posts

Posted - 2007-04-17 : 07:39:54
write the simple script to do the same.why u need to executed in Stored Proc. itself..
Go to Top of Page
   

- Advertisement -