Hi Experts,
Exclude or include where clause based on parameter value,
CREATE TABLE #TEMP ( ID CHAR(1) ) INSERT INTO #TEMP VALUES ( '1' ) INSERT INTO #TEMP VALUES ( '2' ) INSERT INTO #TEMP VALUES ( '3' ) DECLARE @ID CHAR(1) SET @ID = ''--'2' SELECT * FROM #TEMP WHERE 1 = CASE WHEN LEN(@ID) <> 0 THEN @ID ELSE 1 END DROP TABLE #TEMP
Any help?
Thanks
Kumar
Please do let us know your feedback. Thank You - KG, MCTS