SQL Server 2008 Mgmt Studio:使用子查询的任何东西附近的语法都不正确 [英] SQL Server 2008 Mgmt Studio : Incorrect syntax near anything using subquery
问题描述
我运行以下查询
SELECT * FROM
(
SELECT * FROM Client
);
我应该得到客户端中所有字段的列表,而不是我得到
and I should get a list of all fields in client, instead I get
Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near ';'.
我遇到这种情况的唯一原因是用 WITH 子句编写视图,它给了我同样的错误.在此之前,SQL Server Management Studio 2005 已被卸载,并在其位置安装了 2008 Management Studio Express.
The only reason I've come across this was writing a view with a WITH clause and it gave me the same errors. Prior to this, SQL Server Management Studio 2005 was uninstalled, and 2008 Management Studio Express was installed in its place.
知道为什么我不能做任何类型的子查询吗?使用 New Query 并通过 SELECT TOP 1000 ROWS from Client table 尝试了这一点.
Any idea why I cannot do a subquery of any kind? Tried this with New Query and through SELECT TOP 1000 ROWS from Client table.
推荐答案
为内部查询分配别名:
SELECT
*
FROM
(SELECT * FROM Client) AS i
这篇关于SQL Server 2008 Mgmt Studio:使用子查询的任何东西附近的语法都不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!