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

SQL Awesomeness: Finding a QUALIFY query clause in the depths of the database ocean

Look back and realize how far you came

The Greatest Reasons to use or not to use a Centralized Data Access Architecture