【发布时间】:2015-11-14 13:49:53
【问题描述】:
看起来很简单,但我需要这个。我有一个表 tbl(col1,col2,col3)。我想以一种方式在过程中搜索表,就像我只为 col1 传递值时,查询应该只考虑 where 子句中 col1 的值。同样,当我为 col1 和 col2 传递值时,它应该只考虑 where 子句中的这两列并忽略 col3。 我只想使用一个选择查询,例如
'select * from tbl where col1=@col1 and col2=@col2 and col3=@col3'
我原来的过程是:
create proc GetProdData
@source nvarchar(20),
@subsource nvarchar(20)
as
begin
select * From ProductionData
where Source=@source and SubSource=@subsource
end
【问题讨论】:
标签: sql sql-server sql-server-2008 sqlite