Friday, March 9, 2012

Drop Create vs Alter in regards to stored procedures

Anyone have any compelling arguements for using one over the other?

Thanks

Mercy

I'm not sure what the argument would be.

That's like asking if there's an argument to use SELECT, INSERT, UPDATE, OR DELETE.

Adamus

|||

Adamus Turner wrote:

I'm not sure what the argument would be.

That's like asking if there's an argument to use SELECT, INSERT, UPDATE, OR DELETE.

Adamus

I am not sure what your saying.

The question is:

Is there any reason to use

'IF Procedure Exists DROP

Create Procedure'

as opposed to

'ALTER Procedure'

Mercy

|||

I still don't understand what the argument would be. It's purely based on your desired result.

Adamus

|||If the user owns an object and has had create privileges revoked since gaining ownership of the object the ONLY way that the user can make changes is with the ALTER command. This doesn't come up frequently, but it has come a few times.|||

ALTERing a procedure keeps the permissions the same, while DROP and CREATE will require you to set the permissions on the now new stored procedure.

In SQL 2000 and before some people prefer to use DROP and CREATE so that they can see when the procedures were last updated.

Personally I prefer the ALTER method so that any undocumented permissions are preserved instead of destroyed.

No comments:

Post a Comment