游标删除所有存储过程:
1
create
proc
DeleteAllProcedures
2 as
3 declare @procName varchar ( 500 )
4
5 declare cur cursor
6
7 for select [ name ] from sys.objects where type = ' p '
8
9 open cur
10
11 fetch next from cur into @procName
12
13 while @@fetch_status = 0
14
15 begin
16
17 if @procName <> ' DeleteAllProcedures '
18
19 exec ( ' drop procedure ' + @procName )
20
21 fetch next from cur into @procName
22
23 end
24
25 close cur
26
27 deallocate cur
28 go
2 as
3 declare @procName varchar ( 500 )
4
5 declare cur cursor
6
7 for select [ name ] from sys.objects where type = ' p '
8
9 open cur
10
11 fetch next from cur into @procName
12
13 while @@fetch_status = 0
14
15 begin
16
17 if @procName <> ' DeleteAllProcedures '
18
19 exec ( ' drop procedure ' + @procName )
20
21 fetch next from cur into @procName
22
23 end
24
25 close cur
26
27 deallocate cur
28 go