I have problem declaring multible table variables in Microsoft SQL Server. Trying to separate the tables with comma but seems to give me some syntax errors.
Code looks like this. Show both code as sample and as a picture in order for you to see the error marks:
DECLARE
@StructuredProducts TABLE(
StructuredProductId INT
,ArrangerIdv2 INT
,ISIN VARCHAR(50)
,InstrumentId INT
,Caption VARCHAR(100)
,DbRegDate DATE
,EndDate DATE
),
@PriceDataOld TABLE(
StructuredProductId INT
,FinalDate DATE
,FinalPriceDate DATE
,FinalPrice DECIMAL(9,3)
,FinalPriceSek DECIMAL(9,3)
),
@PriceDataEarlyExercise TABLE(
StructuredProductId INT
,EEDate DATE
,EEPriceDate DATE
,EEPrice DECIMAL(9,3)
,EEPriceSek DECIMAL(9,3)
),
@PriceDataActive TABLE(
StructuredProductId INT
,ActiveDate DATE
,ActivePriceDate DATE
,ActivePrice DECIMAL(9,3)
,ActivePriceSek DECIMAL(9,3)
)
To address your comment
Isn't comma the way to declare multiple variables?
well, yes a comma can be used to declare multiple local variables and cursors, but not table variables - the docs explicitly say this:
n
Is a placeholder indicating that multiple variables can be specified and assigned values. When declaring table variables, the table variable must be the only variable being declared in the
DECLARE
statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With