请问我的解释有什么错误,需要创建一个表值函数。
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