SQL Server 2008 Mgmt Studio:使用子查询的任何内容附近的语法不正确 [英] SQL Server 2008 Mgmt Studio : Incorrect syntax near anything using subquery

查看:15
本文介绍了SQL Server 2008 Mgmt Studio:使用子查询的任何内容附近的语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行以下查询

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 表.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆