34,590
社区成员
发帖
与我相关
我的任务
分享
--这样?
declare @tab table (id int IDENTITY (1, 1) NOT NULL ,char1 nvarchar(100))
insert into @tab select '1035,1036'
union all select '1035,1,2'
declare @char1 varchar(10)
set @char1='1'
select * from @tab where charindex(','+@char1+',',','+char1+',')>0
declare @tab table (id int IDENTITY (1, 1) NOT NULL ,char1 nvarchar(100))
insert into @tab
select '1035,1036'
union all
select '1035,1,2'
select * from @tab where charindex(',1,' , ','+char1 + ',')>0
select * from @tab where ','+char1 + ',' like '%,1,%'
/*
id char1
----------- ----------
2 1035,1,2
(所影响的行数为 1 行)
id char1
----------- ----------
2 1035,1,2
(所影响的行数为 1 行)
*/