![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Re: ALTER proc vs IF EXISTS DROP/CREATE
Optional Create and Alter is nice because it fails, the original is
still in place as are the original permissions. Drop and create is also valid in some cases if you want to clear/reset the permissions. I use an approach which lets me choose which one I want to implement on the fly. If I remove the first two dashes, the drop is disabled and it creates only if it doesn't already exist. Otherwise it drops, creates a filler sproc, and then alters with the real sproc... --/* remove the two dashes at the beginning of this line to convert it from a drop/create/alter to just a create/alter. IF OBJECT_ID('dbo.spr_SprocTemplate') IS NOT NULL DROP PROCEDURE dbo.spr_SprocTemplate --*/ IF OBJECT_ID('dbo.spr_SprocTemplate') IS NULL BEGIN EXEC ('CREATE PROCEDURE dbo.spr_SprocTemplate AS SELECT 1') EXEC ('GRANT EXECUTE ON dbo.spr_SprocTemplate TO db_sprocexecutor') -- custom role that has permissions to execute sprocs END GO ALTER PROCEDURE dbo.spr_SprocTemplate AS BEGIN --Procedure SET NOCOUNT ON SELECT END --Procedure GO GO Hope that Helps! -Eric Isaacs |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|