alter proc proc_ttt
@show varchar(10),
@str varchar(100),
@table nvarchar(200),
@val int
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
if(@show='yes')
begin
set @tmp ='update '+rtrim(@table)+' set control=left(control,'+cast(@val - 1 as char)+')+''1''+substring(control,'+cast(@val + 1 as char)+',len(control)-'+cast(@val as char)+') where id in(select X from #t)';
end
else
begin
set @tmp ='update '+rtrim(@table)+' set control=left(control,'+cast(@val - 1 as char)+')+''0''+substring(control,'+cast(@val + 1 as char)+',len(control)-'+cast(@val as char)+') where id in(select X from #t)';
end
--print @tmp
exec(@tmp)