I have below query to select set of record based on the ccmflag
condition.
CREATE OR ALTER PROCEDURE [dbo].[getdata]
@p_ccmflag BIT = 0
AS
SELECT *
FROM dbo.data
IF @p_ccmflag = 1
BEGIN
WHERE CCMFlag = 1
END
ELSE
BEGIN
WHERE CCMFlag != 1
END
ORDER BY 1 ASC;
I am getting this error:
Msg 156, Level 15, State 1
Incorrect syntax near the keyword 'where'.
1条答案
按热度按时间pw9qyyiw1#
Earlier someone posted an answer, I tried that query and its working fine for me.
Query as below: