Passing SQL stored procedure entirety of WHERE clause

后端 未结 5 2036
隐瞒了意图╮
隐瞒了意图╮ 2020-12-11 19:01

I have a SQL stored procedure of the form

SELECT [fields] FROM [table] WHERE @whereSql

I want to pass the procedure an argument (@whereSql)

5条回答
  •  隐瞒了意图╮
    2020-12-11 19:31

    http://sqlmag.com/t-sql/passing-multivalued-variables-stored-procedure

    try this it works!!

    CHARINDEX (',' + ColumnName + ',', ',' +
    REPLACE(@Parameter, ' ', '') + ',') > 0
    

    execute syntax set @Parameter= 'nc1,nc2'

提交回复
热议问题