Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Data update from one database to another database (Insert and Update both) Expand / Collapse
Author
Message
Posted Monday, December 24, 2012 3:13 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, August 15, 2013 11:49 AM
Points: 48, Visits: 269
Hi,
I have 2 database tables.
1) From Production
2) From Dev.
The task is to move the data from Production to Dev Server.
But the issues is that when the data is already exist then it will update else if no record exist in Dev Server then it will insert.

Existence of Data is checked through one column.

please respond asap if you have any good solution.
Post #1399853
Posted Monday, December 24, 2012 6:33 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 7:35 AM
Points: 2,817, Visits: 2,563
This is pretty straight forward in SSIS

In a dataflow,
-create a source from your prod server.
-Lookup records on your dev server. In SQL Server 2005 I believe you have to set it to ignore the failure
-Create a conditional split that compares the value in your source (prod) to the value you target (dev)
-In the split where they match send the data to a staging table
-In the split where they don't match send the data to be inserted to your target.

After the data flow runs, build an Execute SQL Task that takes the matched data from your staging table and updated the target (dev) data.
Post #1399879
Posted Monday, December 24, 2012 9:46 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, August 15, 2013 11:49 AM
Points: 48, Visits: 269
thanks. its working in some of my test sample data.
Post #1399930
Posted Wednesday, December 26, 2012 7:45 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 7:35 AM
Points: 2,817, Visits: 2,563
Daniel Bowlin (12/24/2012)
This is pretty straight forward in SSIS

In a dataflow,
-create a source from your prod server.
-Lookup records on your dev server. In SQL Server 2005 I believe you have to set it to ignore the failure
-Create a conditional split that compares the value in your source (prod) to the value you target (dev)
-In the split where they match send the data to a staging table
-In the split where they don't match send the data to be inserted to your target.

After the data flow runs, build an Execute SQL Task that takes the matched data from your staging table and updated the target (dev) data.


A couple of revisions
In the no match, that actually would get sent to an update process, not insert
There should be a null in some of your lookup values, the nulls would be the new records that should be inserted.
Post #1400250
Posted Wednesday, December 26, 2012 8:45 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, August 15, 2013 11:49 AM
Points: 48, Visits: 269
Thanks a lot.
Post #1400266
Posted Sunday, December 30, 2012 6:44 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 25, 2014 4:36 PM
Points: 178, Visits: 576
Since you just want to duplicate the table, you might find it quicker and simpler to just bulk reload the entire table, depending on data volume.
Post #1401279
Posted Monday, December 31, 2012 9:10 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 8:19 AM
Points: 163, Visits: 474
Have you considered replication? That might be an option.
Post #1401411
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse