SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Poor Man (dev) Version Control


Poor Man (dev) Version Control

Author
Message
josephollero
josephollero
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 358
There is a way to create a version control within the database without the need of third party tools. It involves creating a database trigger and the current development operation (i.e. save the stored proc version).

This is useful for having a version of the objects being worked on but it will need a pretty good interface for it to be friendly. But bottomline, we should have a version for everytime we save a stored proc.

Let me know if this line is interesting. Thanks!
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)

Group: General Forum Members
Points: 218806 Visits: 13362
There are free tools out there... ;-)

edit: didn't notice this thread was in the Articles Requested forum.
It might be interesting yes :-)


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Steve Jones
Steve Jones
SSC Guru
SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)

Group: Administrators
Points: 544426 Visits: 20703
Sure thing. It would be interesting to see how this works for you.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Jamie Ingram-729524
Jamie Ingram-729524
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1286 Visits: 467
http://www.sqlservercentral.com/scripts/source+control/66285/

We are the pilgrims, master.
We shall go always, a little further.

josephollero
josephollero
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 358
Here's the summary for it.

Over the years I have reviewed different source controls and have implemented TFS. I'm a DBA at heart it's not nice nice not being able to have a source control for database development especially that clients cannot afford the expensive ones.

I came upon a database trigger post which I modified to make a rough version control for our team.

It involves 2 things
1. Create a Trigger on the database where you want versioned
2. Create a database to save the versions of the things your working on. The DB need only contain 1 specific table.


How does it work
1. This tool saves every time you make changes on your objects -- assuming that the way you save your changes is by running it.
These include the following
- Views
- Tables
- Stored procs
- Functions
2. The database trigger event takes care of the saving. Everytime you press F5 on a alter proc, it will save a copy of your work on the target table which is preferably on another database on the save server.
3. To retrieve the data, you just need to query the data in the table.


The Database Trigger

CREATE TRIGGER [DDLTrigger_Sample]
ON DATABASE
FOR CREATE_PROCEDURE, ALTER_PROCEDURE, DROP_PROCEDURE,ALTER_SCHEMA, ALTER_FUNCTION,CREATE_FUNCTION,DROP_FUNCTION,ALTER_VIEW,CREATE_VIEW,DROP_VIEW,RENAME,ALTER_TABle,CREATE_TABLE
AS
BEGIN
SET NOCOUNT ON;
DECLARE
@EventData XML = EVENTDATA();

DECLARE
@ip VARCHAR(32) =
(
SELECT client_net_address
FROM sys.dm_exec_connections
WHERE session_id = @@SPID
);

INSERT AuditDB.dbo.DDLEvents
(
EventType,
EventDDL,
EventXML,
DatabaseName,
SchemaName,
ObjectName,
HostName,
IPAddress,
ProgramName,
LoginName
)
SELECT
@EventData.value('(/EVENT_INSTANCE/EventType)[1]', 'NVARCHAR(100)'),
@EventData.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'NVARCHAR(MAX)'),
@EventData,
DB_NAME(),
@EventData.value('(/EVENT_INSTANCE/SchemaName)[1]', 'NVARCHAR(255)'),
@EventData.value('(/EVENT_INSTANCE/ObjectName)[1]', 'NVARCHAR(255)'),
HOST_NAME(),
@ip,
PROGRAM_NAME(),
SUSER_SNAME();
END




GO

SET ANSI_NULLS OFF
GO

SET QUOTED_IDENTIFIER OFF
GO

ENABLE TRIGGER [DDLTrigger_Sample] ON DATABASE
GO




The Table

CREATE TABLE [dbo].[DDLEvents](
[EventDate] [datetime] NOT NULL,
[EventType] [nvarchar](64) NULL,
[EventDDL] [nvarchar](max) NULL,
[EventXML] [xml] NULL,
[DatabaseName] [nvarchar](255) NULL,
[SchemaName] [nvarchar](255) NULL,
[ObjectName] [nvarchar](255) NULL,
[HostName] [varchar](64) NULL,
[IPAddress] [varchar](32) NULL,
[ProgramName] [nvarchar](255) NULL,
[LoginName] [nvarchar](255) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[DDLEvents] ADD DEFAULT (getdate()) FOR [EventDate]





If you find this interesting, I'd like to take a shot at an article for it. If not, nice to have posted here and shared Smile.
gbritton1
gbritton1
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5326 Visits: 1012
That looks like an approach to audit changes. Is it full source-control? That is, can I, using your idea, see who changed what specifically (not just that a proc or table ddl changed, but what changed -- that is, what the old was and what the new is)? Would I be able to rollback/revert a change at will? What convention would you use for capturing the reason for a change? How would you relate two or more related changes (that is, a changeset)?
Steve Jones
Steve Jones
SSC Guru
SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)SSC Guru (544K reputation)

Group: Administrators
Points: 544426 Visits: 20703
Take a shot as an article. It's an interesting solution, though it does miss the diff/branch/merge aspects of VCS.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search