Alter Or Create Procedure?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devlin
    New Member
    • Mar 2008
    • 14

    Alter Or Create Procedure?

    HI.

    I have to Alter a procedure if it exists or Create the procedure if it doesn't in SQL Server 2005.
    I can manage to determine if it exists or not, but when i have the code to create and alter in the IF... ELSE statement it doesn't seem to work. It still trys to create it when it exists or alter when it doesn't. I would prefer not to drop the procedure if it exists...
    Any help or advice would be greatly appreciated.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    The CREATE PROCEDURE statement cannot be combined with other Transact-SQL statements in a single batch. That's according to this .

    Try using a dynamic query to create or alter your stored proc.

    Good luck.

    -- CK

    Comment

    • devlin
      New Member
      • Mar 2008
      • 14

      #3
      Thanks for the quick reply. I have sorted my problem out.

      Comment

      Working...