Friday, February 17, 2012

CREATE, ALTER, why wont it save?

when i create a new stored proc, i say "CREATE PROCEDURE [sprocName]"

but the next time i edit the stored proc, it hasnt changed to "ALTER ..."

I manually change it to ALTER, and run it, and close it, and it reverts back to "CREATE..."

Is there some sort of privelage i have to enable? Has anyone encountered this before?

Help guys, please :-S

Also, if you know of a better place where i can post this thread, please let me know Smile

The script you are editing is the crate script for the SP. To update the sp you do an alter but the create script will still be a create.

How are you doing this?

In v2000 enterprise manager clicknig on OK updates the SP even though it's a create.

In v2005 a modify from management studion generates an alter script.

It's better to maintain SPs from disk based scripts in a query window. The first statment should be a conditional drop of the SP followed by a create.

if object_id('mysp') is not null -- or something like that

drop proc mysp

go

create proc mysp

as

....

go

|||

thanx Nigel, the IF OBJECT_ID() IS NOT NULL works Big Smile

now atleast query analyser doesnt tell me:

Server: Msg 2714, Level 16, State 5, Procedure [spName], Line 16
There is already an object named '[spName]' in the database.

Smile

No comments:

Post a Comment