SQL query filtering by list of parameters

后端 未结 3 1853
悲&欢浪女
悲&欢浪女 2021-01-19 02:13

I have a query where I want to return all the rows which are associated with a list of values. You could write this very simply as:

select * from TableA whe         


        
3条回答
  •  孤城傲影
    2021-01-19 02:44

    You can also use multiple resultsets and send a bounch of query like this:

    select * from TableA where ColumnB = @value0
    select * from TableA where ColumnB = @value1
    select * from TableA where ColumnB = @value2
    ...
    select * from TableA where ColumnB = @valuen
    

    in a single call. even if apparently counter intuitive it leverages execution plan and is safe in term of parametrization.

提交回复
热议问题