SQL Server using in keyword pass string array query

前端 未结 3 1083
日久生厌
日久生厌 2021-01-16 20:28

I don\'t think the IN clause can accept bind parameters with multiple values. Oracle can\'t and a couple minutes

and query is

declare @setting varch         


        
3条回答
  •  孤街浪徒
    2021-01-16 21:05

    In SQL Server 2016+: using string_split built in function. Please note, that extra single quotes are not necessary anymore:

    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
    

    If you run SQL Server older than SQL 2016, the answer of @GuidoG is a preferable method

提交回复
热议问题