SQL Server store multiple values in sql variable

后端 未结 6 901
春和景丽
春和景丽 2020-12-29 15:02

I have the following query:

select * 
from cars 
where make in (\'BMW\', \'Toyota\', \'Nissan\')

What I want to do is store the where param

6条回答
  •  温柔的废话
    2020-12-29 15:27

    Fetch 1 value in table and store in variable    
    =======================================================================================
    
    Declare @query int
    
        select @query = p.ProductID From Product p inner join ReOrdering as r on 
        p.ProductID = r.ProductID and r.MinQty >= p.Qty_Available
    
        print @query
    

提交回复
热议问题