Qualify Object Names bug with table variables
sognibene
Posts: 11
Consider the following code:
If you run "Qualify Object Names" on this code (SSMS 2012 SP1, SQL Prompt 6.1.0.101), it transforms the last line to say...
...which is invalid SQL.
DECLARE @MyTable TABLE ( ID INT NOT NULL PRIMARY KEY, Name VARCHAR(200) NOT NULL, [Address] VARCHAR(200) NULL ); INSERT INTO @MyTable ( ID, Name, Address ) VALUES ( 1, -- ID - int 'test', -- Name - varchar(200) '123 Main St.' -- Address - varchar(200) ) SELECT * FROM @MyTable WHERE ID = 1;
If you run "Qualify Object Names" on this code (SSMS 2012 SP1, SQL Prompt 6.1.0.101), it transforms the last line to say...
SELECT * FROM @MyTable WHERE @MyTable.ID = 1;
...which is invalid SQL.
Comments
Note: the private build only had minimal testing so if you'd rather stay with 6.1.0.101 then a work around would be to give the variable an alias which prompt will then qualify the column with.