/****** Object:  UserDefinedFunction [dbo].[F_DESC_ABATIDO]    Script Date: 08/17/2012 10:42:01 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[F_DESC_ABATIDO]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[F_DESC_ABATIDO]
GO
CREATE FUNCTION [dbo].[F_DESC_ABATIDO] (@CD_EMP INT, @CD_FILIAL INT, @CD_RC_DEB INT) RETURNS MONEY
AS
  begin
	RETURN ISNULL((SELECT SUM(VL_DESC) VL_DESC 
					FROM RC_CRED 
					WHERE CD_EMP = @CD_EMP AND CD_FILIAL = @CD_FILIAL AND CD_RC_DEB = @CD_RC_DEB),0)
  end
