Red Gate forums :: View topic - Declared table names getting quoted
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

Declared table names getting quoted

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



Joined: 08 Jul 2008
Posts: 20

PostPosted: Tue Aug 26, 2014 2:40 pm    Post subject: Declared table names getting quoted Reply with quote

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:
Declare @Work table
    (
      FieldA int,
      FieldB varchar(10)
    )

Select *
From @Work As w

Then, remove the table alias "As w".
Code:
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 [@Work]
From @Work

Finally, you can finish the intellisense and add the fields.
Code:
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
Back to top
View user's profile Send private message
Aaron Law



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

PostPosted: Tue Aug 26, 2014 3:42 pm    Post subject: Reply with quote

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:

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