Translate

Friday, 31 August 2018

drop all procedure in a database in sql server , select all procedure in a sql server database

drop all procedure in a database in sql server
declare @userProcedureName varchar(2000)
declare drop_proc_cur cursor
for select [name] from sys.objects where type = 'p'
open drop_proc_cur
fetch next from drop_proc_cur into @userProcedureName
while @@fetch_status = 0
begin
--print @userProcedureName;
   exec('drop procedure [' + @userProcedureName + ']')
   fetch next from drop_proc_cur into @userProcedureName
end
close drop_proc_cur

deallocate drop_proc_cur




 select all procedure in a sql server database 

 select [name] from sys.objects where type = 'p'

No comments:

Post a Comment