我有代码......
DECLARE @y AS INT = xxx; --IF THIS IS NULL THEN WE WANT EVERYTHING RETURNED
SELECT column
FROM table
WHERE y >= @y;
如何设置此项以便IF @y IS NULL
然后忽略where子句并返回所有内容?
答案 0 :(得分:3)
SELECT some_column
FROM your_table
WHERE (@y is null or y >= @y)