TSQL中的括号-奇怪、预期还是错误?
尝试运行以下四个SQL命令我正在使用MS SQL Server Management Studio 2012,连接到SQL Server 2012 11.0:TSQL中的括号-奇怪、预期还是错误?,sql,sql-server,sql-server-2012,Sql,Sql Server,Sql Server 2012,尝试运行以下四个SQL命令我正在使用MS SQL Server Management Studio 2012,连接到SQL Server 2012 11.0: select 'hello' from anytable (select 'hello' from anytable) select 'hello' from anytable order by 1 (select 'hello' from anytable order by 1) 前三个跑得很好。第四个给出了错误: 消息156,
select 'hello' from anytable
(select 'hello' from anytable)
select 'hello' from anytable order by 1
(select 'hello' from anytable order by 1)
前三个跑得很好。第四个给出了错误:
消息156,级别15,状态1,第1行关键字附近语法不正确
“命令”
知道发生了什么吗?使用括号表示查询是一个子查询,不能在子查询中使用order By操作。然后可以使用top关键字来消除子查询中的错误,但在这里,即使使用top,也会显示errorYes,最初使用top,但它不起作用。把它简化下来,就简化到上面。我觉得这很奇怪…你能试试百分之一百吗?看起来像BUG@NoDisplayName-同意。还没有弄清楚确切原因,但请从任意表order by 1 works中选择“hello”。