Solved

SSIS SQL Server 2014 Data Flow's Applied Logic

Posted on 2016-08-09
3
87 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
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

863 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

27 Experts available now in Live!

Get 1:1 Help Now