回答:
CTEはビュー内に入ります。
CTEでクエリを実行する
WITH cte AS (...) SELECT ...;
CREATE VIEW AS .. GOを追加するだけです
CREATE VIEW
AS
WITH cte AS (...) SELECT ...;
GO
MSDNは複数のCTEについて説明しています(例jを参照)
CREATE VIEW
AS
WITH
cte1 AS (...),
cte2 AS (...),
cte3 AS (...)
SELECT ...
GO
CREATE VIEW
someview
AS
WITH CTEstuff AS (SELECT etc)
SELECT * FROM CTESTuff;
create view myView as ( select ... )
正常にcreate view myView as with tempTbl as select ...
動作create view myView as ( with tempTbl as select ... )
しますが、構文エラーです。`