Sees like a bug for SQL SERVER 2005
2008-01-17 13:03
369 查看
What do you guess the result of this Query:
SELECT TOP 2 * FROM (SELECT TOP 3 * FROM [SqlBug]) AS T
ORDER BY col1 DESC ;
and this is the scripts for table [SqlBug]:
CREATE TABLE [dbo].[SqlBug](
[col1] [int] NULL,
[col2] [nchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[col3] [int] NULL
) ON [PRIMARY]
the test data in the table is :
col1 col2 col3
1 A 11
2 A 12
3 B 12
4 C 13
5 D 14
6 E 15
My expect result is :
3 B 12
2 A 12
but the real result is :
6 E 15
5 D 14
The "ORDER BY col1 DESC" sentence should act on the outer select but not the inner select. I think it 's most reason is the PRI for "ORDER BY" and parenthesis when used with "Top", so is this a bug for sql server 2005?
SELECT TOP 2 * FROM (SELECT TOP 3 * FROM [SqlBug]) AS T
ORDER BY col1 DESC ;
and this is the scripts for table [SqlBug]:
CREATE TABLE [dbo].[SqlBug](
[col1] [int] NULL,
[col2] [nchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[col3] [int] NULL
) ON [PRIMARY]
the test data in the table is :
col1 col2 col3
1 A 11
2 A 12
3 B 12
4 C 13
5 D 14
6 E 15
My expect result is :
3 B 12
2 A 12
but the real result is :
6 E 15
5 D 14
The "ORDER BY col1 DESC" sentence should act on the outer select but not the inner select. I think it 's most reason is the PRI for "ORDER BY" and parenthesis when used with "Top", so is this a bug for sql server 2005?
相关文章推荐
- Kimberly L. Tripp的sp_helpindex2 for sql server 2005/2008,并修复了for sqk2k8的一个bug
- Sample Databases for SQL Server 2000/2005
- Suggested Max Memory Settings for SQL Server 2005/2008
- JDBC Driver 驱动 For SQL 2008 Server /2005 /2000
- Connection strings for SQL Server 2005 http://www.connectionstrings.com/
- JDBC For SQL Server 2005
- 读书笔记——Microsoft SQL Server 2005 Express Edition For Dummies
- ArcSDE 9.1 for Sql Server 2005安装报告
- SQL Server Express 2005 Beta 两处BUG及解决方案
- Restore SQL Server 2005 error : "The tail of the log for the database "TEST1" has not been backed up."
- Configuring Internet Information Services for SQL Server 2005 Compact Edition Remote Data Access and Merge Replication
- Feature Pack for Microsoft SQL Server 2005[下载]
- A Developer's Guide to Data Modeling for SQL Server: Covering SQL Server 2005 and 2008
- Configuring SQL Server Express 2005 for Remote Access
- sqlserver Enterprise 2005 安装Bug
- Microsoft SQL Server Migration Assistant 2005 for MySQL使用方法
- Microsoft SQL Server 2005 Reporting Services For Dummies
- ArcIMS 9.2 直连 ArcSDE for Sql Server 2005 Express
- 查找未使用的非聚集索引和表 for sql server 2005/2008
- Microsoft SQL Server 2005 Programming For Dummies