|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:27 PM
Points: 41,
Visits: 157
|
|
| I would like to add something to SSIS package, which will allow it to only insert rows that don't already exist in the database table. Customer table export from a cloud based software exports the entire customer list, so I don't have an option to export just new customers. How can this be accomplished?
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Today @ 12:08 PM
Points: 4,238,
Visits: 9,480
|
|
How will you identify whether a customer already exists - what is the PK?
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:27 PM
Points: 41,
Visits: 157
|
|
| There is a PK in place, which is a Customer ID.
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Today @ 12:08 PM
Points: 4,238,
Visits: 9,480
|
|
Cool - is it an ascending number?
The reason I ask: one way to do this would be to query your existing data, get max(id) and then get the new data by selecting from it where id > maxid.
By the way, what happens if changes to existing data occur - don't you want to update that too?
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 12:27 PM
Points: 41,
Visits: 157
|
|
Phil Parkin (3/6/2013) Cool - is it an ascending number?
The reason I ask: one way to do this would be to query your existing data, get max(id) and then get the new data by selecting from it where id > maxid.
By the way, what happens if changes to existing data occur - don't you want to update that too?
Yes, ascending number. It is auto generated by the system, and customers are never deleted. In this case I'm only interested in appending the data.
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Today @ 12:08 PM
Points: 4,238,
Visits: 9,480
|
|
OK, here's one way.
1) Create an integer variable in your SSIS package - say MaxId. 2) An an ExecuteSQL task which connects to your target db (the one you are importing to) and does something like this:
select MaxId = max(Id) from dbo.Customers
3) Configure the ExecuteSQL task to return the result into the MaxId variable.
4) Create a data flow task and add an OLE DB source. Define the connection as your source db.
5) Set the data access mode to SQL Command.
6) Write the SQL command text, using a parameterised query to select [column list] where Id > MaxId.
7) Connect the OLEDB source to a suitable configured OLEDB destination.
____________________________________________________________________________________________
Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
|
|
|
|