SQL Server使用in关键字传递字符串数组查询

SQL Server使用in关键字传递字符串数组查询,第1张

SQL Server使用in关键字传递字符串数组查询

在SQL Server 2016+中:使用

string_split
内置函数。请注意,不再需要多余的单引号:

DECLARE @setting varchar(max)set @setting ='Sales Entry Grid Cursor,Customer Mandatory,Column Uom,Show Marka,Show Discount Amount In Grid,Show Discount % In Grid,Calculation based on Weight *rate'Select pageconfig_action from [RetailSoft].[dbo].[tbl_pageconfig] Where [PageConfig_settingsName] in(SELECt value FROM string_split(@setting, ',') ) and PageConfig_CompanyId=1

如果您运行的SQL Server早于SQL 2016,则@GuidoG的答案是一种更好的方法



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5640668.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存