How do I write an IF statement with multiple arguments in T-SQL?
Current source error:
DECLARE @StartDate AS DATETIME
DECLARE @EndDate AS DATETIME
SET @StartDate = NULL
SET @EndDate = NULL
IF (@StartDate IS NOT NULL AND @EndDate IS NOT NULL)
BEGIN
-- do some work
END
It throws the following error:
Incorrect syntax near the keyword 'AND'. Incorrect syntax near the keyword 'AND'. Incorrect syntax near ')'.
BEGINandEND. Or, if you have nothing between theBEGINandEND, that would be the problem.--do some worksection that was causing the issue. I am building a dynamic SQL statement...ugh!Incorrect syntax near 'END'.because of the empty block. Putx:before the comment (or a real statement).