2
我想創建一個函數來返回遞歸值,但我得到一個語法錯誤。用於返回遞歸值的SQL函數
CREATE FUNCTION getObs
(
@obs int
)
RETURNS
WITH ret2 AS(
SELECT *
FROM OBS
WHERE OBS_Id = @obs
UNION ALL
SELECT t.*
FROM OBS as t INNER JOIN
ret2 r ON t.OBS_Id = r.UnitId
)
SELECT *
FROM ret2 r
WHERE unity_id = 7
什麼是錯誤? – Szymon