January 3, 2004 at 8:17 pm
Your thoughts on using SELECT "AliasName" = ColName vs. SELECT ColName AS "AliasName". ColName could also be calculated data (either string concatenation or numeric).
I find having a mixture of alias names and table column names all on the left side is easier to follow than to have the table column names on the left and column aliases on the right.
SELECT
OrderID,
ProductID,
"Amount" = UnitPrice * Quantity,
"Long Case" = CASE
WHEN .....
WHEN .....
ELSE ...
END
versus the harder to follow (at least for me)
SELECT
OrderID,
ProductID,
UnitPrice * Quantity AS "Amount",
CASE
WHEN .....
WHEN .....
ELSE ...
END AS "Long Case"
From the research I have done thus far, "AS" is ANSI complient whereas "=" is not. Microsoft's "Best Practices Analyzer" didn't complain about the "=" as long as I enclosed the alias name in quotes.
So as long as the code is written strictly for SQL Server, the "=" should be OK unless MS decides to remove this from future versions?
January 3, 2004 at 9:39 pm
This sounds like it may be a religious issue. I guess it all depends on what you're used to. I've always used ColName as AliasName and I've found it to be very readable. I tend to line up my aliases in a column so I can immedidately recognize which columns are aliased.
I would think you're fine as long as you're consistent.
January 3, 2004 at 11:48 pm
Note in all the system procs, MS use 'aaa' = and not AS.
I personally use AS the same way jxflagg does. Makes it easy to read.
Reason why Microsoft's "Best Practices Analyzer" didn't complain. They do it
Cheers,
Crispin
Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!
January 4, 2004 at 12:08 pm
Actually I only want to ask if you can be really sure to always develop against SQL Server? Although which style you choose depends on personal preferences, but I would stick to the ANSI Standard. I guess that's what standards are for
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
January 5, 2004 at 12:38 am
Functionality should be the same. Physical implementation might not be. I'd stick to aht ANSI standard. cfr isnull and coalesce.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
January 5, 2004 at 1:05 am
ANSI is the way to go. but if you stick to ANSI standards you wont be able to use functions. Some of the additional features provided my MS SQL are not ANSI standard.
I am not sure if ANSI supports functions
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply