码迷,mamicode.com
首页 > 其他好文 > 详细

多条件删除

时间:2018-07-28 15:58:06      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:name   多条件   int   rop   删除   HERE   var   create   sel   


----删除-----

create proc up_del
@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
GO

多条件删除

标签:name   多条件   int   rop   删除   HERE   var   create   sel   

原文地址:https://www.cnblogs.com/JXSBoKeYuan/p/9382174.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!