if exists (select name from dbo.sysobjects where name='fGetMandeHesab') drop function fGetMandeHesab go create function fGetMandeHesab(@fcId int, @orgId int, @tafId bigint) returns decimal(19,4) as begin declare @mande decimal(19,4); set @mande=( select sum(isnull(bes,0.0))-sum(isnull(bed,0.0)) from dbo.fAllCodeBedBes(@fcId,@orgId,0 , 20000000) where ID =@tafId ) return @mande; end