T-SQL - CREATE VIEWでCTEを使う
CREATE VIEWのSELECT句でCTEを使えることを知ったのでサンプルクエリを残しておきます。
CTEの中身は適当です。
use Test;
drop view if exists dbo.Sample;
go
create view dbo.Sample
as
-- 1~10までの連番を生成するCTE
with Cte as (
select 1 as Value
union all
select Value + 1
from Cte
where Value < 10
)
select *
from Cte;
go
select *
from dbo.Sample;
/*
Value
----------
1
2
3
4
5
6
7
8
9
10
*/