CREATE TABLE #Temp (ids INT)
INSERT INTO #Temp VALUES (1)
INSERT INTO #Temp VALUES (2)
INSERT INTO #Temp VALUES (3)
INSERT INTO #Temp VALUES (4)
INSERT INTO #Temp VALUES (5)
Condition :
If I pass parameter as -1 it should return records having ids 1 or 3.
If I pass parameter as 5 it should return only records having ids 5.
DECLARE @a INT
--SET @a = -1
SET @a = 5
SELECT * FROM #Temp WHERE ((ids = 1 OR ids = 3) AND @a = -1) OR ids = @a
Subscribe to:
Post Comments (Atom)
1 comment:
Wow! Excellent
Post a Comment