declare @str varchar(200)
set @str = '3,314,311,312,313,316,325,2223,2224,2225,327,319,321,2219,2221,2226'
select 2544, lxbh,20120327 from t_table where lxbh in (@thlxs)
因为t_table 中的lxbh是int型,[email protected]
------解决方案--------------------
declare @str varchar(200)
set @str = '3,314,311,312,313,316,325,2223,2224,2225,327,319,321,2219,2221,2226'
exec('select 2544, lxbh,20120327 from t_table where lxbh in ([email protected]+''')')[code=SQL][/code]
------解决方案--------------------
------解决方案--------------------
declare @str varchar(200)
set @str = '3,314,311,312,313,316,325,2223,2224,2225,327,319,321,2219,2221,2226'
select 2544, lxbh,20120327 from t_table where ',[email protected]+',' like '%,'+ltrim(lxbh)+',%'
------解决方案--------------------
用动态或用patindex/charindex/like
- SQL code
declare @str varchar(200)set @str = '3,314,311,312,313,316,325,2223,2224,2225,327,319,321,2219,2221,2226'select 2544, lxbh,20120327 from t_table where charindex('%,'+rtrim(lxbh)+',%',',[email protected]+',')>0