stored proc - executing a query with NOT IN where clause

后端 未结 5 739
梦谈多话
梦谈多话 2021-01-26 09:58

i have a stored procedure

Create PROCEDURE abc      
  @sRemovePreviouslySelectedWhereClause nvarchar(max)
AS
BEGIN

SELECT * 
      FROM table 
     WHERE nId          


        
5条回答
  •  萌比男神i
    2021-01-26 10:21

    You will need to use Dynamic sql for such kind of queries.

    first construct the query and

    SET @sql = 'select * from table 
    where nId not in (' + @sRemovePreviouslySelectedWhereClause+ ')'
    

    then use EXEC(@sql) to run the query.

提交回复
热议问题