.NET学习爱好者

热爱编程事业

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 

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)

posted on 2007-01-11 19:55  风景  阅读(157)  评论(0编辑  收藏  举报