Failed to compile the following:
DECLARE
@DateFrom Date = '20151225',
@DateTo Date = '20151226',
@Ids TABLE (Id Int NOT NULL);
with an error:
Incorrect syntax next to the keyword "TABLE".
But when I add my own DECLAREto declare a table variable, it compiles fine:
DECLARE
@DateFrom Date = '20151225',
@DateTo Date = '20151226';
DECLARE
@Ids TABLE (Id Int NOT NULL);
Here is the SQL script.
What is wrong with the first fragment? Are we not allowed to declare table variables that share the same block DECLAREwith other variable declarations?
source
share