在将 varchar 值 '6,7,8,9,20,21' 转换成数据类型 int 时失败。
select * from table1 where id in (select id1s from table2 where id2=1)
id1是int类型的,id1s是varchar类型的
------解决方案--------------------
- SQL code
declare @str varchar(100)
select @str = id1s from table2 where id2=1
select * from table1 where charindex(','+ltrim(id)+',',','+@str+',') > 0