SQLSERVER 2000 升级 2005 ORDER BY 兼容性问题
ALTER DATABASE [MyDataBase]
SET COMPATIBILITY_LEVEL = 80;
GO
SELECT orderCol = 1, * FROM(select 1 myTable) SourceTable ORDER BY SourceTable.orderCol;
-- 可以通过
ALTER DATABASE [MyDataBase]
SET COMPATIBILITY_LEVEL = 90;
GO
SELECT orderCol = 1, * FROM(select 1 myTable) SourceTable ORDER BY SourceTable.orderCol;
-- 不可以通过
-- 求问不改兼容级别,不改代码,如何破?
ALTER DATABASE ttt
SET COMPATIBILITY_LEVEL = 90;
GO
SELECT orderCol=1, *
FROM(select 1 myTable) SourceTable
ORDER BY orderCol;
/*
orderColmyTable
11
*/
SELECT * FROM
(SELECT orderCol=1,*
FROM(select 1 myTable) SourceTable) SourceTable
ORDER BY SourceTable.orderCol