公共表表达式,为什么要用分号?
通常在SQL Server
公共表表达式子句中,语句前面有分号,如下所示:
;WITH OrderedOrders AS --semicolon here
(
SELECT SalesOrderID, OrderDate,
ROW_NUMBER() OVER (ORDER BY OrderDate) AS 'RowNumber'
FROM Sales.SalesOrderHeader
)
SELECT *
FROM OrderedOrders
WHERE RowNumber BETWEEN 50 AND 60
为什么?
Usually in SQL Server
Common Table Expression clause there is semicolon in front of the statement, like this:
;WITH OrderedOrders AS --semicolon here
(
SELECT SalesOrderID, OrderDate,
ROW_NUMBER() OVER (ORDER BY OrderDate) AS 'RowNumber'
FROM Sales.SalesOrderHeader
)
SELECT *
FROM OrderedOrders
WHERE RowNumber BETWEEN 50 AND 60
Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
..FROM..WITH (NOLOCK)..
RESTORE..WITH MOVE..
;
终止语句SQL Server放在一起,前面的语句必须在WITH/CTE 之前终止。为了避免错误,大多数人使用
;WITH
因为我们不知道 CTE 之前是什么所以
相同。
与MERGE 命令具有类似的要求
..FROM..WITH (NOLOCK)..
RESTORE..WITH MOVE..
;
in SQL ServerPut together, the previous statement must be terminated before a WITH/CTE. To avoid errors, most folk use
;WITH
because we don't know what is before the CTESo
is the same as
The MERGE command has a similar requirement.