locked
Incorrect syntax near '@actualYear'. RRS feed

  • Question

  • User-1506965535 posted

    When running the below SP, I get error as

    Incorrect syntax near '@actualYear'.

    ALTER PROCEDURE Monthly_leave_Allocation_2016
    
    @Year int,
    @Month int
    
    AS
    BEGIN	
    	
    	BEGIN
    	   declare  @actualMonth int
    	  declare @actualYear int
    	  declare @actuallastdate datetime
     	    
    	   IF	(@Month = 1)
    			  BEGIN
    				  @actualYear = (@Year - 1)
    				  @actualMonth = 12
    			  END	
    	    ELSE
    			  BEGIN
    				@actualMonth = @Month - 1
    				@actualYear = @Year
    			  END
    	       
        END	      
       	
    END
    GO

    What is the issue here ?

    Thursday, December 17, 2015 11:03 AM

Answers

  • User452040443 posted

    Try:

    	   IF	(@Month = 1)
    			  BEGIN
    				set @actualYear = @Year - 1
    				set @actualMonth = 12
    			  END	
    	    ELSE
    			  BEGIN
    				set @actualMonth = @Month - 1
    				set @actualYear = @Year
    			  END

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 17, 2015 11:33 AM

All replies

  • User452040443 posted

    Try:

    	   IF	(@Month = 1)
    			  BEGIN
    				set @actualYear = @Year - 1
    				set @actualMonth = 12
    			  END	
    	    ELSE
    			  BEGIN
    				set @actualMonth = @Month - 1
    				set @actualYear = @Year
    			  END

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 17, 2015 11:33 AM
  • User-1506965535 posted

    yes, i tried just that and it worked.

    anyways Thanks.

    Thursday, December 17, 2015 11:38 AM