xiaoandong

万能批量删除

go---创建万能批量删除

drop proc dele
go
create proc dele
@TableName varchar(50),
@Id varchar(5000),
@IdName varchar(20)
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 \'+@IdName+\' in ( select ID from #DelID)\'

exec(@strSql)
end

发表于 2018-07-29 19:14  D-dada  阅读(112)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-07-24
猜你喜欢
  • 2021-12-18
  • 2021-07-08
  • 2021-07-21
  • 2021-04-17
  • 2022-12-23
  • 2021-07-15
  • 2022-02-08
相关资源
相似解决方案