SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Brackets in SQL Server

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Brackets in SQL Server
Author Message
seth.rothman



Joined: 29 Jan 2008
Posts: 54
Country: United States

Post Brackets in SQL Server Reply with quote
I'm testing v4 and just came across something I'm not sure was occurring in 3.5 or not. When I alias a column name within square brackets, the intellisense still does its thing (which I believe is incorrect). For example: (this is a totally made up example & makes no real sense)

SELECT a.account_id, CASE WHEN a.account_status = 'Closed' THEN 1 ELSE 0 END AS [Account is Closed]
FROM dbo.Account a

You can't actually alias the column properly because the "is" gets capitalized and you can never actually write the word "Closed". I believe whatever you're typing within [ ]'s should be typed as-is with no intellisense.
Sat Oct 04, 2008 3:59 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7847

Post Reply with quote
SQL Assistant never supported use of brackets in column/expression aliases. However, it always supported ANSI compatible syntax using double-quoted aliases, e.g. SELECT my_column_or_expresison AS "My Alias With Spaces" as well as SELECT "My Alias With Spaces" = my_column_or_expresison


BTW, using brackets in column/expression aliases doesn't seem to be documented feature of T-SQL. I've personally never seen it used and when I saw your post I went to straight MS books online site and rechecked the syntax for column aliases. Books only mention regular aliases with no spaces and no brackets, and also provide unexplained example of an alias in single quotes. I believe that single quotes in aliases are also virtually never used by professional SQL developers. Just my 2 cents…
Sat Oct 04, 2008 8:58 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
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
Design by Freestyle XL / Flowers Online.