Ran into something little that I know I’m going to forget if I don’t write down. It appears that when using a TABLE variable in tsql ( SQL Server 2005 ), you must DECLARE that variable on it’s own line, as opposed to inline with your other @variables.
Typically in my sprocs or sql scripts I do my best to have a main DECLARE block and seperate my @variables with a comma like this.
After some mucking around, it turns out moving the TABLE @variable to it’s own DECLARE line fixes this issue.
I haven’t found this info in SQL BOL, so I hope this helps somebody else.
Tags: #table, DECLARE, SQLSERVER, SQLSERVER 2005, table variable, tsql





