alter proc proc_ttt
@str varchar(100),
@table nvarchar(200)
as
declare @t table(a varchar(1000)) declare @i int
declare @tmp varchar(1000)
CREATE TABLE #t(x varchar(2000))
set @str = @str+','
set @i=0
while @i<=len(@str)
begin
set @i=charindex(',',@str)
insert into #t select ''+left(@str,@i-1) +''
set @str=right(@str,len(@str)-@i)
end
--select X from #t
set @tmp ='delete from ['+ @table+'] where id in(select X from #t)'
--print @tmp
exec(@tmp)
exec proc_ttt '1111111,11111','admin'