Solved

SSIS SQL Server 2014 Data Flow's Applied Logic

Posted on 2016-08-09
3
59 Views
Last Modified: 2016-08-13
I have a SSIS 2014 Package created in Visual Studio 2013. I have successfully performed a simple Data Flow from one table to another. I am now wondering how to apply additional logic: 1. Check for Existence of data, then either update or insert new data into a table's column, and 2. Avoid data duplication. Any help on coding C# or T-SQL for this small, modest task would be greatly appreciated. Thank you.
0
Comment
Question by:ladesigner2014
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 500 total points
Comment Utility
I assume here that you have already defined the criteria for Record Duplication.
To determine whether you have data to work with in the first place you can place a RowCounter component between the Source and Destination in your data flow. You will need to define an integer variable for this, and provide that variable to the RowCounter component (edit it).
After the flow completes your variable will be set to the number of records transferred. You can use the value of the variable to determine where to go next in Control Flow by having two blue ("on completion") lines from your Data Flow task. Right click them and change their properties and you should be able to edit them to have a condition, such as "User::intNrRecs > 0" for one and "User::intNrRecs != 0" for the other

For the "update or insert" operation you will be performing what is known as an "upsert" ! There are two ways of doing this with SSIS, and there's articles on each by Reza Rad linked to from here that you might find useful (I'm giving a link because they're several pages long!). The explanations are long, but the techniques aren't difficult.

Hope this helps

Mike
0
 

Author Closing Comment

by:ladesigner2014
Comment Utility
This helped a lot! Thank you!
0
 
LVL 16

Expert Comment

by:DcpKing
Comment Utility
Hi ladesigner2014
Thanks very much for answering and confirming. Very often points are awarded, but the original author never says much about how things turned out. It's great to hear that I could help you - hopefully we here at EE can help with your next problem too!

Mike
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now