Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SSIS SQL Server 2014 Data Flow's Applied Logic

Posted on 2016-08-09
3
Medium Priority
?
187 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 2000 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how the fundamental information of how to create a table.

722 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