declare @id_sz varchar(200)
set @id_sz='70,73,76,05'
select * from aTable where id_sz in (@id_sz) //这样查询不到信息
//如果用拼SQL语句的方式则或以,但我不能用那种方式
------解决方案--------------------
--这样,用动态SQL.
- SQL code
declare @id_sz varchar(200) set @id_sz='70,73,76,05' exec('select * from aTable where id_sz in ([email protected]_sz+')')
------解决方案--------------------
- SQL code
--或者这样。declare @id_sz varchar(200) set @id_sz='70,73,76,05' select * from aTable where charindex(','+id_sz+',',',[email protected]_sz+',')>0
------解决方案--------------------
2楼也可,就是效率没有 1楼好.