0
我想創建一個函數,它需要返回一個表,但即使函數也不是,我需要返回結果表。如何在SQL Server中聲明表?
我的劇本就像是返回table這個
create function FNC_getPackageListById(@PkId int)
returns table
as
return
if exists (select Date1, Date2 from PromotionPackage
where PkId = @PkId and Date1 is null and Date2 is null)
begin
select Rate,Remarks,PackageName from Package where [email protected]
end
else
begin
select p.Rate,
p.Remarks,
p.PackageName,
pp.Date1,
pp.Date2
from PromotionPackage pp,
Package p
where pp.PkId=p.PkId and [email protected]
end
end