SQL in (@Variable) query

前端 未结 3 760
时光取名叫无心
时光取名叫无心 2020-12-11 18:23

I have the following code, the problem is that my variable list @LocationList is essentially a csv string. When I use this as part of the where LocationID in (@LocationList

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 19:24

    declare @querytext Nvarchar(MAX)
    
    set @querytext = 'select Locations from table where Where LocationID in (' + @LocationList + ');';
    
    exec sp_executesql @querytext;
    

提交回复
热议问题