首页 > 资讯列表 > 编程/数据库 >> 数据库操作教程

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

数据库操作教程 2022-09-23 20:38:24 转载来源: 网络整理/侵权必删

修改:复制代码代码如下:declareproccurcursorforselect[name]fromsysobjectswherenamelike'Foods_%'declare@procnamevarchar(100)declare@tempvarchar(100)openproccurfetchnextfromproccurinto@procnamewhile(@@FETCH_STATUS=0)beginset@temp='kcb_'+@procnameEXECSP_RENAME@procname,@tempprint(@procname+'已被删除')fetchnextfromproccurinto@procnameendcloseproccurdeallocateproccurdeclareproccurcursorforselect[name]fromsysobjectswherenamelike'kcb%'declare@procnamevarchar(100)declare@tempvarchar(100)declare@temp2varchar(100)declare

修改
复制代码 代码如下:

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

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

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

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

删除:
复制代码 代码如下:

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

标签: 批量 存储 过程 sqlserver 删除 修改 语句


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2024 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持