This article makes a good point about losing permissions when dropping an object in SQL server.
- Tips āNā Tricks ā T-SQL ā An Elegant way to CREATE or ALTER Stored Procedures in One-Go for Easy Maintenance
So here is the approach which retains permissions:
IF OBJECT_ID('spCallSomething') IS NULL
EXEC('CREATE PROCEDURE spCallSomething AS SET NOCOUNT ON;')
GO
ALTER PROCEDURE spCallSomething ...
--instead of DROP/CREATE
Also works for functions, just replace PROCEDURE with FUNCTION in the above code.
Another reason to consider doing it this way is tolerance to failure. Suppose your DROP succeeds, but your CREATE fails – you end with a broken DB. Using ALTER approach, you will end up with an older version of the object.