کدش شبیه اینه
createFunction [dbo].[udf_SumPrice](
@idenID bigint
)
returns bigint
as
begin
Declare @Sum bigint
select @Sum =SUM(Price) from "tblName" where idenID =@idenID
tblName.idenID =@idenID
if @Sum is null
set @Sum =0

return @Sum
end

حالا این select روبنویس
select dbo.SumPrice from "tblname"