SQL 함수가 있는데 테이블을 반환하려고하지만 오류가 발생합니다. A RETURN statement with a return value cannot be used in this context
. 여기 SQL 함수에서 테이블을 반환하는 방법
ALTER FUNCTION [dbo].[Fnc_GetParentCategories]-- 21
(
@catId int
)
Returns table
As
Begin
Declare @Table table(Id int identity(1,1),Category_Id int,ParentId int);
declare @cid int;
WITH x AS (
SELECT a.Category_Id, a.ParentId
FROM t_Category a
WHERE [email protected] -- enter dead node walking here
UNION ALL
SELECT b.Category_Id, b.ParentId
FROM t_Category b
JOIN x ON x.Category_Id =b.ParentId
)
insert into @Table select * from x;
return @Table
end
그리고 오류는 다음과 같습니다
A RETURN statement with a return value cannot be used in this context
당신이지고있는 오류를 게시 할 수 방금 전에 테이블 정의를 선언? 문제를 더 빠르게 식별하는 데 도움이됩니다. –
반환 값이있는 RETURN 문은이 컨텍스트에서 사용할 수 없습니다. – Cronaldo