There is no difference in the underlying functionality of the two types of aliasing (
as opposed to
=). What it boils down to is exactly what you mentioned: Readability and maintainability.
In my opinion the former (
<Expression> as <Alias>) is much more readable as it is self explanatory. When you have
SELECT ColumnName = 1 I think it'd be pretty easy to mistake that as setting a variable on those long tired nights. You might mistake that as
SELECT @ColumnName = 1 and that would be completely different functionality. Therefore, to circumvent any possibility of the query "double look", or even worse...error in understanding/coding, I go with
SELECT 1 as ColumnName 100% of the time.
Personal preference, but consistency (for yourself and within your team) is king. Whatever you find easiest, go with and do it all the time. There is nothing more frustrating than switching back and forth for somebody troubleshooting/reviewing/maintaining code.
The third unmentioned way is to use
<Expression> <Alias>. In other words, your second way without the
as keyword. I think this is just as bad as the
= symbol. It lacks readability at the gain of what? Not typing three extra characters (
as and a space). Not worth it.
For exaggeration purposes, take a look at a query like this:
[New Name] = Name,
NewDepId = DepartmentID,
GroupName as GName,
Not code that I'd want to review.