Qualify Object Names bug with table variables

sognibenesognibene Posts: 11
edited December 2, 2013 6:42AM in SQL Prompt
Consider the following code:
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

  • Thank you for the detailed recreation steps! I think I have a fix and I've made a private build for you which you can download from here.

    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.
Sign In or Register to comment.