Cannot Alter Procedure Containing Variables

  • When I run this code in QA,

    ALTER PROCEDURE [dbo].[sp_DAILYMOVEMENTS]@MyDate DateTime, @CID INT AS

    DELETE MOVEMENT WHERE COM_COMPANYID_N = @CID

    ...

    I get this error

    Server: Msg 137, Level 15, State 2, Line 3

    Must declare the variable '@MyDate'.

    But if I code the sproc as CREATE then it will run fine.

    I have altered sprocs before, I don't know why it is a problem today?


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

  • It works fine for me when I do the create and the alter. Are you using SQL Server 2000? I notice that the error was in line 3... are you sure that your ALTER PROCEDURE statement is the first statement in the batch?

    John

  • Yes exactly, your error messages states that the error is in line 3. Please select only this part of the script and try executing.

    Prasad Bhogadi
    www.inforaise.com

  • Yes, it is SS2000, though I never can decipher the error messages headers of 'State X, Level Y' apart from the 'Line 3' part.

    But I think I fixed the problem, it was way down the code, in a join clause.

    Thanks for the response.


    Regards,

    goodguy

    Experience is a bad teacher whose exams precede its lessons

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply