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