SQL Server 2008 Mgmt Studio:使用子查询的任何内容附近的语法都不正确

发布于 2024-10-17 21:48:45 字数 411 浏览 2 评论 0原文

我运行以下查询

SELECT * FROM
(
    SELECT * FROM Client
);

,我应该获得客户端中所有字段的列表,而不是我

Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near ';'.

遇到的唯一原因是编写带有WITH子句的视图,它给了我同样的错误。在此之前,已卸载 SQL Server Management Studio 2005,并安装了 2008 Management Studio Express。

知道为什么我不能执行任何类型的子查询吗?使用 New Query 并通过从 Client 表中选择 TOP 1000 ROWS 尝试了此操作。

I run the following query

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 ';'.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

他夏了夏天 2024-10-24 21:48:45

为内部查询分配别名:

SELECT
    *
FROM
    (SELECT * FROM Client) AS i

Assign an alias to the inner query:

SELECT
    *
FROM
    (SELECT * FROM Client) AS i
丑丑阿 2024-10-24 21:48:45

试试这个:

 SELECT * FROM
(
    SELECT * FROM Client
)A;

Try this:

 SELECT * FROM
(
    SELECT * FROM Client
)A;
初心 2024-10-24 21:48:45

为什么不呢

SELECT * FROM Client

SELECT TOP 1000 * FROM Client 

如果您想限制返回的行数,

如果您的查询更复杂,您可以使用 公用表表达式

Why don't you just

SELECT * FROM Client

and

SELECT TOP 1000 * FROM Client 

if you want to limit the number of rows returned

If your query is more complicated you could use a common table expression

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文