Red Gate forums :: View topic - Qualify Object Names bug with table variables
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Prompt 6
SQL Prompt 6 forum

Qualify Object Names bug with table variables

Search in SQL Prompt 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
sognibene



Joined: 28 May 2013
Posts: 7

PostPosted: Sun Dec 01, 2013 10:19 pm    Post subject: Qualify Object Names bug with table variables Reply with quote

Consider the following code:

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...

Code:
SELECT  * FROM @MyTable WHERE @MyTable.ID = 1;


...which is invalid SQL.
Back to top
View user's profile Send private message
Aaron Law



Joined: 28 Jun 2013
Posts: 192
Location: Red Gate Software

PostPosted: Mon Dec 02, 2013 12:42 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group