 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
seth.rothman
Joined: 29 Jan 2008 Posts: 54 Country: United States |
|
Brackets in SQL Server |
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
|
|
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
|
|
|