sqlserver 批量删除存储过程和批量修改存储过程的

网络编程 2021-07-05 13:42www.168986.cn编程入门
sqlserver 批量删除存储过程和批量修改存储过程的语句,需要的朋友可以参考下。
修改
代码如下:

declare prour cursor
for
select [name] from sysobjects where name like 'Foods_%'
declare @proame varchar(100)
declare @temp varchar(100)
open prour
fetch next from prour into @proame
while(@@FETCH_STATUS = 0)
begin
set @temp='kcb_'+@proame
EXEC SP_RENAME @proame,@temp

print(@proame + '已被删除')
fetch next from prour into @proame
end
close prour
deallocate prour

declare prour cursor
for
select [name] from sysobjects where name like 'kcb%'
declare @proame varchar(100)
declare @temp varchar(100)
declare @temp2 varchar(100)
declare @temp3 varchar(100)
open prour
fetch next from prour into @proame
while(@@FETCH_STATUS = 0)
begin
set @temp3= LEN(@proame)
set @temp='kcb_'
set @temp2=RIGHT(@proame,@temp3-3)
set @temp+=@temp2
EXEC SP_RENAME @proame,@temp

print(@proame + '已被修改')
fetch next from prour into @proame
end
close prour
deallocate prour

删除
代码如下:

declare prour cursor
for
select [name] from sysobjects where name like 'Users_%'
declare @proame varchar(100)
open prour
fetch next from prour into @proame
while(@@FETCH_STATUS = 0)
begin
exec('drop proc ' + @proame)
print(@proame + '已被删除')
fetch next from prour into @proame
end
close prour
deallocate prour

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by