Improper syntax for table variables

Provides intelligent code completion for SQL Server editors.

Moderators: JonathanWatts, David Atkinson, Anu Deshpande, Paul Stephenson, Michelle Taylor, Mike Upton, justin.caldicott, Aaron Law

Improper syntax for table variables

Postby blitzd » Sun Jan 27, 2013 6:25 pm

When I bring up SQL Prompt intellisense from this point:

Code: Select all
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: Select all
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: Select all
(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.
blitzd
 
Posts: 32
Joined: Fri Nov 26, 2010 7:30 pm

Postby chriskelly » Mon Jan 28, 2013 8:49 pm

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
chriskelly
 
Posts: 330
Joined: Mon Apr 19, 2010 1:44 pm
Location: Cambridge, UK


Return to SQL Prompt 5

Who is online

Users browsing this forum: No registered users and 0 guests