Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Replication (2005)
 Replicate => SQL?

Author  Topic 

X-Factor
Constraint Violating Yak Guru

392 Posts

Posted - 2009-03-20 : 11:28:42
Hi,

I know very little about Replication, but I'm just wondering, is it possible to have replication export database changes to SQL scripts as the changes happen?

If so, then one could put the scripts in source control and they'd be totally in synch with source code.

Cheers, XF.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-03-20 : 15:22:26
Why not sync up with other database in same server or diff server?
Go to Top of Page

X-Factor
Constraint Violating Yak Guru

392 Posts

Posted - 2009-03-21 : 03:50:40
Because the idea is to transform the database into a form that's easy to put into source control.

Aren't you just suggesting a copy of a database? What I'm after is being able to have source control keep track of all the changes made to a database so that you can step back through time to different versions of it - or at least, different versions of the SQL which could be used regenerate it.
Go to Top of Page

greenantim
Starting Member

1 Post

Posted - 2009-03-23 : 14:01:13
You could try using DDL triggers. This would enable you to monitor changes to tables, stored procedures etc and capture the sql statement that triggered the change. In the trigger you could then insert the sql statement into a table. You could write a simple .net application that reads the table and writes the sql statement to a text file. It could also automate the checkin process in to the source control system.

The following topic in books on line describes DDL triggers -
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/d79e5725-adea-4934-9474-9cd975adb6d8.htm

BTW - capturing database changes after the fact is not a good idea. You should have controls in place so that no changes are made to the database unless they have been reviewed and approved, in which case you should already have the changes in your source control system.
Go to Top of Page

X-Factor
Constraint Violating Yak Guru

392 Posts

Posted - 2009-03-24 : 19:59:48
quote:

BTW - capturing database changes after the fact is not a good idea. You should have controls in place so that no changes are made to the database unless they have been reviewed and approved, in which case you should already have the changes in your source control system.


Surely that's a bit over the top when developing?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-03-24 : 20:03:06
I don't see the original question answered yet, so I'll answer it. Replication can't be used for this.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-03-24 : 21:11:39
quote:
Surely that's a bit over the top when developing?
Not at all, and it will make your development process a lot smoother. Not to mention QA, UAT and production deployments. The antithesis of a stable database platform are developers/development process that is never reviewed. If you haven't suffered (and I do mean SUFFERED) from this yet, you are lucky, and it won't last.

The fact is, if your developers are going about their day making constant changes to the database schema, they aren't designing, and they should stop. Get the team together for half a day and hammer out at least the tables that are needed. You'll save a ton of time in the long run.

Once that's done, script them out, check them into source control, and enable/enforce a build procedure from this source control. It doesn't have to be in the dev environment, but at least somewhere that can be used as a reference. When you go to deploy, you can use Red Gate or Data Dude or a similar tool to compare the current environment to the reference. You could also check this differential script into your source control, but for proper version control you must regenerate the scripts when you do an actual release.
Go to Top of Page

Itamar
Starting Member

19 Posts

Posted - 2009-03-27 : 03:09:43
quote:
Originally posted by X-Factor

Hi,

I know very little about Replication, but I'm just wondering, is it possible to have replication export database changes to SQL scripts as the changes happen?

If so, then one could put the scripts in source control and they'd be totally in synch with source code.

Cheers, XF.



Hi,
You can use a 3rd party tool for SQL version control, like Randolph -
[url]http://nobhillsoft.com/Randolph.aspx[/url]

Nob Hill Software - Tools for Database People
SQL Version Control, Database Compare, Query Tools and more. www.nobhillsoft.com
Go to Top of Page
   

- Advertisement -