declare @lkaklf as varchar(Max)
Select ss.Data from SplitString('14,72', ',') as ss
Select @lkaklf = CONVERT(varchar, COALESCE( + @lkaklf + ',', '') + '''' + Data + '''') From
(
Select Data from SplitString('14,72', ',')
)de
select @lkaklf
print @lkaklf
Select * from LPO Where CONVERT(varchar, LPO.LocalPurchaseOrderId) in (@lkaklf)
@lkalf值是在消息中打印但未进入选择查询...为什么?
答案 0 :(得分:0)
你无法做你想做的事。我建议你跳过查询的拆分部分,然后执行:
where ','+@lkaklf+',' like ','+cast(LPO.LocalPurchaseOrderId as varchar(255))+',%'
也就是说,只需使用字符串比较。
如果确实想要使用SplitString()
,请将结果放在临时表中:
insert into @t
select data from splitstring('14,72', ',')
然后使用子查询:
where cast(@lkalklf as varchar(255)) in (select data from @t)