Red Gate forums :: View topic - Improper syntax for table variables
Return to www.red-gate.com RSS Feed Available

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

Improper syntax for table variables

Search in SQL Prompt 5 forum
Post new topic   Reply to topic
Jump to:  
Author Message
blitzd



Joined: 26 Nov 2010
Posts: 31

PostPosted: Sun Jan 27, 2013 6:25 pm    Post subject: Improper syntax for table variables Reply with quote

When I bring up SQL Prompt intellisense from this point:

Code:
DECLARE @Table TABLE ( ID INT )
INSERT  INTO @Table
        ( ID
        )
        SELECT TOP 10
                object_id
        FROM    sys.all_objects

SELECT  *
FROM    sys.all_objects
WHERE   object_id IN ( SELECT   ID
                       FROM     @T


...and let it autocomplete, it results in this:

Code:
DECLARE @Table TABLE ( ID INT )
INSERT  INTO @Table
        ( ID
        )
        SELECT TOP 10
                object_id
        FROM    sys.all_objects

SELECT  *
FROM    sys.all_objects
WHERE   object_id IN ( SELECT   ID
                       FROM     [@Table] )


...and that is just NOT proper syntax for selecting from a table variable, there should be no squared brackets. Running the statement (with the closing parentheses) will result in:

Code:
(10 row(s) affected)
Msg 208, Level 16, State 1, Line 6
Invalid object name '@Table'.


When using SQL Prompt to auto-complete the insert into a the table variable, it works correctly.
Back to top
View user's profile Send private message
chriskelly



Joined: 19 Apr 2010
Posts: 309
Location: Cambridge, UK

PostPosted: Mon Jan 28, 2013 8:49 pm    Post subject: Reply with quote

Thank you for your post.

It looks like you have encountered a bug in the tool. I have therefore logged a bug report with the developers. Hopefully they will be able to come up with a fix for the next release. Unfortunately, I cannot yet say when this release will come.
_________________
Chris Kelly
Technical Support Engineer
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