Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Alter Or Create Procedure?

Question posted by: devlin (Newbie) on July 4th, 2008 05:39 AM
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's Avatar
ck9663
Expert
1,353 Posts
July 4th, 2008
06:07 AM
#2

Re: Alter Or Create Procedure?
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

Reply
devlin's Avatar
devlin
Newbie
14 Posts
July 4th, 2008
07:54 AM
#3

Re: Alter Or Create Procedure?
Thanks for the quick reply. I have sorted my problem out.

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,876 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Microsoft SQL Server Contributors