USE [Billing] GO /****** Object: StoredProcedure [dbo].[sp_Billing_LoadDiscountRates] Script Date: 10/04/2011 17:09:42 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[sp_Billing_LoadDiscountRates] @DiscountType varchar(2), @AccountNum varchar(10), @SubType varchar(1) = '', @IdNum varchar(12) = '1' AS if @DiscountType = 'BH' begin select RevenueID, Rate, case when NetPHIC = 1 then 'Y' else 'N' end NetPHIC from BUILD_FILE..tbCoDiscountRates where DiscountType = @DiscountType and SubType = @SubType end else if exists (select top 1 RevenueID from BUILD_FILE..tbCoDiscountRates where DiscountType = @DiscountType and AccountNum = @AccountNum ) begin select RevenueID, Rate, case when NetPHIC = 1 then 'Y' else 'N' end NetPHIC from BUILD_FILE..tbCoDiscountRates where DiscountType = @DiscountType and AccountNum = @AccountNum end else begin -- select RevenueID, Rate, -- case when NetPHIC = 1 -- then 'Y' -- else 'N' -- end NetPHIC -- from BUILD_FILE..tbCoDiscountRates -- where DiscountType = @DiscountType -- and AccountNum = '' If IsNumeric(@IDNUM) = 1 OR @IDNUM = '' begin select RevenueID, Rate, case when NetPHIC = 1 then 'Y' else 'N' end NetPHIC from BUILD_FILE..tbCoDiscountRates where DiscountType = @DiscountType and AccountNum = '' end Else begin select RevenueID, isNull(OPRAte,0) as Rate, case when NetPHIC = 1 then 'Y' else 'N' end NetPHIC from BUILD_FILE..tbCoDiscountRates where DiscountType = @DiscountType and AccountNum = '' End end