周泉

宁可危险,有些疯癫,没有遮掩。

导航

T-SQL WITH 分号问题

使用with 前面有sql语句时候

运行

with tempTbale(id) as (
select .....
)
select * from tempTbale

运行上面语句 提示下面错误

Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

从stackoverflow找到解释,需要在with前加";",

;with tempTbale(id) as (
select .....
)
select * from tempTbale

链接如下:

Msg 319, Level 15, State 1, “Incorrect syntax near the keyword 'with'.”

MSDN 定义如下

WITH common_table_expression (Transact-SQL)

转自Enzo技术小站:T-SQL WITH 分号问题

posted on 2014-06-27 11:46  周泉  阅读(1124)  评论(0编辑  收藏  举报