简体   繁体   中英

How to track changes in development environment in SQL Server

Our development team works on SQL Server and writes stored procedures for our product.

We need something like a version control system for those procedures or any other objects.

Sometimes I change a stored procedure, and someone else in my team changes it and I don't know any thing about it.

Is there any solution for that?

If you want to do it via code you could run this on a daily or hourly basis to get a list of all procs that were changed in the last day:

select * 
from sys.objects 
where datediff(dd, create_date, getdate()) < 1 
   or datediff(dd, modify_date, getdate() < 1) 
   and type = 'P';

or you could create a ddl trigger:

Create trigger prochanged On database
For create_procedure, alter_procedure,  drop procedure
as 
begin
    set nocount on

    Declare @data xml
    set @data = Eventdata()

    -- save @data to a table...
end

This will allow you to save all kinds of information every time a proc is created, changed or deleted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM