That is by design:
Quote:
When a CTE is used in a statement that is part of a batch, the statement before it must be followed by a semicolon.
You must read the
documentation[
^] carefully.
I guess they needed that semicolon to parse the statement correctly as WITH can be used for other things too e.g. hints in selects:
SELECT * FROM MyTable WITH (NOLOCK)
or options in some commands:
ALTER TABLE MyTable REBUILD WITH (DATA_COMPRESSION = PAGE).
It is similar to
MERGE[
^] command which must always be terminated by a semicolon.