还是update动态SQL的问题,第三次了

ms222ms252288601 ms222ms252288601 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
数据库中有表test,列为:
id A1 A2 A3 B1 B2 B3
-----
要求用变量@id,@name,@pro,来修改“test”表
若@name=A1 and @pro=B1,则修改@id的A1值为“1”,B1值为“1”
若@name=A2 and @pro=B1,则修改@id的A2值为“1”,B1值为“1”
....
若@name=A6 and @pro=B2,则修改@id的A6值为“1”,B2值为“1”
存储过程为:
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
-----
这样一次执行单行没问题。
问题是,在我的gridview中,每行数据后,都有一个checkbox,如果选中单行的话,可以修改成功。选中多行,只有第一行起作用。
我把where id = ' + cast(@id as varchar)改为:where id in ' + cast(@id as varchar)
也不行,应该怎么该?
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
ms222ms252288601
疑难问题 22,298 成员 121,727 内容