If you use an ‘Order By
’ clause, in ASE you can freely mix column names and column aliases which you can prefix with a table name or a table alias.
In MS SQL Server, a column alias cannot be prefixed with a table name or table alias.
Example
create table Tab (Col varchar(30))
select Col from Tab as T order by Col
select Col from Tab as T order by T.Col
select Col as C from Tab as T order by T.Col
select Col as C from Tab as T order by C
select Col as C from Tab as T order by Col
go
-- This statement will not work on MS SQL Server
select Col as C from Tab as T order by T.C
go
drop table Tab
Note: If you choose a unique column alias, there is no need to prefix it.