Problem: Sometimes we need to recreate sp in database in this case we need to remove all current sp from database.
Solution:
declare @procName varchar(500)
declare cur cursor
for select [name] from sys.objects where type = 'P'
open cur
fetch next from cur into @procName
while @@fetch_status = 0
begin
print @procName
exec('drop procedure ' + @procName)
fetch next from cur into @procName
end
close cur
deallocate cur
Solution:
declare @procName varchar(500)
declare cur cursor
for select [name] from sys.objects where type = 'P'
open cur
fetch next from cur into @procName
while @@fetch_status = 0
begin
print @procName
exec('drop procedure ' + @procName)
fetch next from cur into @procName
end
close cur
deallocate cur
No comments:
Post a Comment