Link to home
Start Free TrialLog in
Avatar of dlrickman
dlrickman

asked on

Default Option For Stored Procedure With IF - ELSE Condition

I need to set a default for the stored procedure to begin automatically at type if no value is supplied -    Right now you need to specify 0 for the type condition to begin -----    So Basically the default will automatically check the IF(@Type=0) Condition and maybe a 1 or something else will skip that condition Completely - Any help will be appreciated

CREATE PROCEDURE Report].[Report2]
      
      @StartDate datetime,
      @EndDate datetime,
                @Type tinyint
AS

BEGIN

set transaction isolation level read uncommitted;

                declare @Type tinyint
      declare @pStartDate datetime
      declare @pEndDate datetime
      declare @IsMonthlyReport bit
                set @Type =0
      set @pStartDate = @StartDate
      set @pEndDate = @EndDate

      
      
       

      BEGIN TRY

            set @IsMonthlyReport = [CoRegReport].[rpt_IsMonthlyReport] (@pStartDate, @pEndDate)
       
       
       
       IF(@Type= 0)
       BEGIN
   
            
            
            
       IF (@IsMonthlyReport = 0)
            BEGIN
Avatar of Roman Gherman
Roman Gherman
Flag of Moldova, Republic of image

Hi,
This should help you.

CREATE PROCEDURE Report].[Report2]
      
      @StartDate datetime,
      @EndDate datetime,
                @Type tinyint = 0
AS

Open in new window

Avatar of dlrickman
dlrickman

ASKER

okay but how do you get @Type to Begin as a default if no input parameter is specified
ASKER CERTIFIED SOLUTION
Avatar of Roman Gherman
Roman Gherman
Flag of Moldova, Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial