Here is an article that is very helpful in this matter: Avoid Transact-SQL's Column Alias Limitations
Key points:
- MS SQL only allow alias in SELECT and ORDER BY
- Use sub-query, can help in some cases to re-use column alias
Tips that make life of a software engineer easier. Well, not exactly. Some posts are open questions that I haven't found an answer ... yet
RIGHT('00000' + CAST(myNumber AS VARCHAR), 5) |
<script src="http://gist.github.com/467670.js?file=gistfile1.sql"></script> |
1046: Type was not found or was not a compile-time constant: ?????.