22,211
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
数据库中有表test,列为: set @sql = 'update test set ' + @name + ' = 1 ,'+@pro+'=1 where charindex(id , ''' + cast(@id as varchar) + ''')>0'
CREATE proc Utest
@id as char(10) ,
@name as char(10),
@pro as char(10)
as
begin
declare @sql as char(100)
set @sql = 'update test set ' + @name + ' = 1 ,'+@pro+'=1 where id = ''' + cast(@id as varchar) +''''
exec(@sql)
end
GO