No, there is no way to force that syntax, unless you pass all queries through some 3rd party tool that parses the SQL code and supports looking for syntax like this, but I think it will be very difficult to even approach writing something that will do this.
It is also not possible to stop someone from typing FROM dbo.table nolock
and not realizing that in that case nolock
is an alias, not a locking hint. That is why this works:
SELECT name FROM sys.objects nolock WITH (NOLOCK);
In addition, I find the expression AS alias
syntax far less usable than alias = expression
- since, when I'm reviewing or troubleshooting code, I'm much more likely to need to find a column by its alias at the beginning of a line, than by reading what could be a very long and complex expression, that spans lines or goes off the screen to the right, and ends at a different vertical point than all the other lines. And since aliases should be shorter than expressions, it makes more sense to me to put the alias first.
At the end of the day, though, it's a preference, and no, there is no way to force it. Don't let your developers blame the language for their sloppiness. This is something that should be caught before a second set of eyes ever sees that query. I mean, how hard is it to count how many columns are returned by your query?