Solved

SSIS SQL Server 2014 Data Flow's Applied Logic

Posted on 2016-08-09
3
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 500 total points
ID: 41754868
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
ID: 41754910
This helped a lot! Thank you!
0
 
LVL 16

Expert Comment

by:DcpKing
ID: 41755035
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

630 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