Conditional proc ALTER or CREATE

  • Hi. I am trying to update my db by running a script with a proc change. I need it to be a conditional update, based on my db version number.

    I'm running into an error when I try to have a CREATE or ALTER script within a conditional statement. For e.g.:

    ------------------------------------------------------

    DECLARE @DBVersion VARCHAR(10)

    SET @DBVersion = (SELECT Version FROM DatabaseVersion)

    IF (@DBVersion = '1.0.0')

    BEGIN

          ALTER PROCEDURE dbo.WhateverProc

          ------

    END

    GO

    ------------------------------------------------------

    This results in an error. Replacing the ALTER with a drop and a subsequent CREATE has the same problem. I have no issues running the ALTER or CREATE without any IF statement. I can also do structural changes within my IF, it's only the procs that are giving me problems.

    Is this syntactically impossible to do? If so, any suggestions on other methods to make db updates that are conditional?

    Thank you in advance for any help in this matter!

  • Mehul - please don't cross-post - members on this site monitor all threads...

    please respond to this post here







    **ASCII stupid question, get a stupid ANSI !!!**

Viewing 2 posts - 1 through 1 (of 1 total)

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