Red Gate forums :: View topic - Sync only new rows in a table
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Data Compare 10
SQL Data Compare 10 forum

Sync only new rows in a table

Search in SQL Data Compare 10 forum
Post new topic   Reply to topic
Jump to:  
Author Message
sbacheld



Joined: 24 Apr 2013
Posts: 4

PostPosted: Wed Apr 24, 2013 8:11 pm    Post subject: Sync only new rows in a table Reply with quote

Hi,

We are in the process of automating database updates from our dev -> staging -> production process. One of the tables that we want to use sql data compare for has different values for each of the different environments. So it would look something like this:

dev: name=Row1, timeout=1
staging: name=Row1, timeout=10
production: name=Row1, timeout=15

Now, if we add a new row, we want that new row to get synced to all the databases, but would like any existing rows to remain unaffected. Is this possible with sql data compare? We are running this from the command-line if that makes a difference

Thanks,
Sean
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6647

PostPosted: Thu Apr 25, 2013 9:59 am    Post subject: Reply with quote

Hi Sean,

Unfortunately I can't answer correctly without having the whole schema. SQL Data Compare matches rows based on the primary key or column(s) you choose to use as a row identifier. And it's not state-aware so it can't tell you if there are "new" rows. What you could possibly try is to use a WHERE clause on the tables and views tab and put a selection criteria there -- for instance if your table has a datetime column in it you could sync only records that are newer than 30 days by putting a WHERE clause in to compare only date > GETDATE()-30.
Back to top
View user's profile Send private message
sbacheld



Joined: 24 Apr 2013
Posts: 4

PostPosted: Fri May 03, 2013 5:14 am    Post subject: Reply with quote

Thanks, Brian. We'll investigate a solution along those lines!
Back to top
View user's profile Send private message
wdhenrik



Joined: 19 Jul 2012
Posts: 12

PostPosted: Thu Jun 13, 2013 12:55 am    Post subject: Reply with quote

If "new" rows is defined as rows that don't exist in the other table, you can certainly do this with SQL Data Compare.

Your comparison results are broken down into rows that exist only in the left table (To Insert), rows in both (To update) and rows existing only in the right table (To Delete).

If your new rows are in the left table, only select the records that show up in that section and create your deployment script. You should end up with only insert statements in your deployment script.

I haven't used the command line for this, so I'll have to defer back to RedGate if the command line support the same options the GUI does.

Hope that helps.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group