Declared table names getting quoted

Provides intelligent code completion for SQL Server editors.

Declared table names getting quoted

Postby JimF » Tue Aug 26, 2014 2:40 pm

Another issue I have found (in the current live code as well as the current beta) is that in certain circumstances declared table names get quoted with square brackets.

It's rare and I was only reminded of it when I was using the Output clause in a DML statement with 6.4.0.530 and my "Inserted" table was incorrectly changed to the temp table's name and quoted.

I can contrive an example that shows this bug though. Enter:
Code: Select all
Declare @Work table
    (
      FieldA int,
      FieldB varchar(10)
    )

Select *
From @Work As w

Then, remove the table alias "As w".
Code: Select all
Select *
From @Work

Go to the asterisk and back it out and choose the table name "@Work" from the list, press tab. You then end up with:
Code: Select all
Select [@Work]
From @Work

Finally, you can finish the intellisense and add the fields.
Code: Select all
Select  [@Work].FieldA,
        [@Work].FieldB
From @Work

While this code is apparently legal and runs, I would rather not see it quoted unless needed because of the characters in the name.

If this issue can't be addressed right away, I think I am fine with that as it is pretty rare that this happens.

Thanks again,
Jim
JimF
 
Posts: 23
Joined: Tue Jul 08, 2008 7:55 pm
Location: Phoenix, AZ, USA

Postby Aaron Law » Tue Aug 26, 2014 3:42 pm

Hi Jim,

I'm just playing around with it now and I think the square brackets are actually required here. If I remove them then try to run the statement I get the following error:
Code: Select all
Msg 137, Level 16, State 1, Line 7
Must declare the scalar variable "@Work".
Msg 137, Level 16, State 1, Line 8
Must declare the scalar variable "@Work".



Do you see the same when you try to run the statement without the square brackets?

Thanks,
Aaron.
Aaron Law
 
Posts: 405
Joined: Fri Jun 28, 2013 10:56 am
Location: Red Gate Software


Return to SQL Prompt 6

Who is online

Users browsing this forum: No registered users and 0 guests