27,579
社区成员
发帖
与我相关
我的任务
分享
select * from 表 where ','+@member_id_array+',' LIKE '%,'+RTRIM(id)+',%'
EXEC('select * from 表 where id in ('+@member_id_array+')')
要用动态
-- 使用动态语句
create table test(id int, num int)
go
insert into test values(18,100),(19,100),(20,100),(21,100)
go
print '原始数据'
select * from test
go
declare @array varchar(10) ;
declare @sql varchar(100) ;
set @array = '19,20' -- 你的参数集合
set @sql = 'update test set num = 200 where id in (' + @array + ')'
exec (@sql)
go
print '修改后的数据'
select * from test
go
drop table test
go
(4 行受影响)
原始数据
id num
----------- -----------
18 100
19 100
20 100
21 100
(4 行受影响)
(2 行受影响)
修改后的数据
id num
----------- -----------
18 100
19 200
20 200
21 100
(4 行受影响)