How to add Stored Procedures to Version Control

后端 未结 6 456
礼貌的吻别
礼貌的吻别 2021-01-31 17:53

Our team just experienced for the first time the hassle of not having version control for our DB. How can we add stored procedures at the very least to version control? The cur

6条回答
  •  生来不讨喜
    2021-01-31 18:29

    2nd solution from @Darryl didn't work as suggested by @Moe. I modified @Darryl's template and I got it working, and thought it would be nice to share it with everybody.

    IF NOT EXISTS(SELECT name FROM sysobjects
                  WHERE name = '' AND type = 'P' AND uid = '1')   
        EXEC sp_executesql N'CREATE PROCEDURE dbo.
        AS
        BEGIN
            select ''Not Implemented''
        END
        '
    GO
    
    ALTER PROCEDURE dbo.
    AS  
    BEGIN
      --Stored Procedure Code 
    End
    

    This is really nice because I don't lose my stored procedure permissions.

提交回复
热议问题