我有一个有关SQL Server中通用表表达式的性能问题。我的查询如下
;WITH tempCTE (VolumeID,YZMWF,lvl)
AS
(
select DISTINCT VolumeID, YZMWF ,0 as lvl from YZMDGT where YZMWF=@WorkID
union all
select e.VolumeID, e.YZMWF , cte.lvl + 1 lvl from YZMDGT e inner join tempCTE cte on e.YZMWF=cte.VolumeID and e.VolumeID<>e.YZMWF
)
select DISTINCT * into #dgt from tempCTE