首页新闻找找看学习计划

批量删除存储过程对不对

0
[待解决问题]

go
create proc [dbo].[proc_Delete]
@TableName varchar(50),
@Id varchar(5000)
as
begin
declare @strSql varchar(5000)

declare @sql varchar(4000)

set @sql='select col='''+ replace(@Id,',',''' union all select ''')+''''

if OBJECT_ID('tempdb..#DelID') is not null
drop table #DelID
create table #DelID(ID VARCHAR(36))

insert into #DelID exec(@sql)

set @strSql = 'delete from '+@TableName+' where ID in ( select ID from #DelID)'

exec(@strSql)
end

啊飞达的主页 啊飞达 | 初学一级 | 园豆:104
提问于:2018-07-28 11:26
< >
分享
所有回答(1)
0

对不对自己建个表运行一下试试啊

流年飞雨 | 园豆:1923 (小虾三级) | 2018-07-28 12:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册