Tuesday 25 August 2020

Steps to follow for renaming Stored Procedures

There are two approaches to rename stored procedure. Dropping and Recreating Procedure : The problem is it will lead to losing of permissions. sp_rename of Procedure : Permissions will remain intact. The stored procedure will be renamed. But, sys.sql_modules will still be having the old definition. I prefer the second approach. I followed the below steps:
  1. Have copy of the stored Procedure content Rename the stored procedure
  2. 1:  EXEC sp_rename 'dbo.OldStoredProcedureName','NewStoredProcedureName'  
    2:  GO  
    
  3. ALTER PROCEDURE to have the modified code of the procedure in the sys.sql_modules
  4. 1:  ALTER PROCEDURE dbo.NewStoredProcedureName  
    
  5. Now, Stored procedure name is also updated and code is refreshed in sys.sql_modules and permissions are also intact.

No comments:

How to Handle SSIS Database movement from one environment to another

Below are the steps to follow the movement of SSISDB from one environment to another: -- opening the existing Database master key in S...