sqlserver 将店铺表转换成可以用in查询的字符串
create TABLE #tempshopt (
shopid varchar(max)
)
set @aSql = 'insert into #tempshopt(shopid) select shopid from s_shopid
where shopid in ('+@shop+') and n_leix in (4,5) '
exec(@aSql)
select @shop=''''+SUBSTRING(shopid,3,LEN(shopid)-2)+'''' from (
SELECT distinct (STUFF(( SELECT ''',''' + shopid from #tempshopt a
FOR XML PATH('')), 1, 1, '') ) as shopid FROM #tempshopt AS Test) a