Declaring table variable in SQL Server 2005

When there is a requirement to declare several local variables inside TSQL script, it appears that table variables must have it's own DECLARE clause. Surprisingly, Books Online do not mention that.

Here you go :

DECLARE @str1 varchar(8), @TblList table(TableName varchar(250))

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'table'.

DECLARE @TblList table(TableName varchar(250)), @str1 varchar(8)

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ','.



DECLARE @str1 varchar(8)
DECLARE @TblList table(TableName varchar(250))

Command(s) completed successfully.

Comments

Popular posts from this blog

Unlocking Microsoft Fabric: A Simple Guide when you only have a personal account.

ETL to ELT journey: Break free your Transformations and discover Happiness and Data Zen

Coding is a rollercoaster of efficiency and eyebrow-raising discoveries.