请解释我的错误是什么,需要创建一个表值函数。
CREATE FUNCTION [dbo].[RetrieveEntityParent] (@FK_EntityId int (max))
with p as
(SELECT EntityId, FK_ParentId , EntityName ,EntityArabicName
FROM OrgEntity
WHERE OrgEntity.EntityId=14
UNION ALL
SELECT PA.EntityId, PA.FK_ParentId, PA.EntityName,PA.EntityArabicName
FROM OrgEntity as PA
inner join p
ON p.FK_ParentId = PA.EntityId)
SELECT * from p
答案 0 :(得分:0)
inline table valued function的语法是:
CREATE FUNCTION [dbo].[RetrieveEntityParent] (@FK_EntityId int (max))
RETURNS TABLE
AS RETURN
... your query here ...