日期:2014-05-16 浏览次数:20771 次
declare @param varchar(20)='A:12,B:00,C:00,D:7'
declare @xmlparam xml = convert(xml,'<c>,'+REPLACE(@param,',',',</c><c>,')+',</c>')
;with t as(
select data from(
values('A:12,B:1,C:11,D:3'),('A:11,B:00,C:11,D:3'),('A:00,B:00,C:00,D:3'),
('A:00,B:1,C:11,D:77'),('A:00,B:11,C:22,D:77')) t(data))
select distinct t.data
from t cross apply @xmlparam.nodes('c') t1(condition)
where ','+t.data+',' like '%'+condition.value('.','varchar(20)')+'%'