开发者

is it need to put ';' a semicolon in front of a CTE

开发者 https://www.devze.com 2023-01-31 13:32 出处:网络
is it need to put \';\' a semicolon in front of a CTE? would any one h开发者_C百科ave that idea?

is it need to put ';' a semicolon in front of a CTE? would any one h开发者_C百科ave that idea?

Thank you for the replays.........


Only if the previous statement does not end in ;

I don't personally because I use ; on the end of my statements.

When I answer here on SO, I do for clarity.

"WITH" itself can be used in many places so the ; is needed to enable the parser to determine the WITH context correctly (CTE link)

A contrived example: where is the statement delimiter?

ALTER DATABASE foo SET OFFLINE WITH ROLLBACK IMMEDIATE SELECT * FROM bar

ALTER DATABASE foo SET OFFLINE WITH MYCTE AS (SELECT * FROM bar) SELECT * FROM MYCTE

The same applies to DROP ASSEMBLY or EXECUTE or RECONFIGURE or MERGE

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号