Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TSQL中的括号-奇怪、预期还是错误?_Sql_Sql Server_Sql Server 2012 - Fatal编程技术网

TSQL中的括号-奇怪、预期还是错误?

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,

尝试运行以下四个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,级别15,状态1,第1行关键字附近语法不正确 “命令”


知道发生了什么吗?

使用括号表示查询是一个子查询,不能在子查询中使用order By操作。

然后可以使用top关键字来消除子查询中的错误,但在这里,即使使用top,也会显示errorYes,最初使用top,但它不起作用。把它简化下来,就简化到上面。我觉得这很奇怪…你能试试百分之一百吗?看起来像BUG@NoDisplayName-同意。还没有弄清楚确切原因,但请从任意表order by 1 works中选择“hello”。