Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SSIS - Add new data rows

Posted on 2010-08-30
3
Medium Priority
?
643 Views
Last Modified: 2013-11-10
Hello,

I am using SQL Server Business Intelligence Development Studio 2005 and I have the following problem:

I have a dataset, consisting of different attributes. If one attribute value consists exactly of the String "string1/string2", the string must be splitted into "string1" and "string2".  The splitted "string2" has to be added as a new row in the same table and schould keep the same values for the others attributes as "string1/string2".

How can I realize this issue?

Thanks.
0
Comment
Question by:TSYSTEMS_LOBPLM
[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 30

Expert Comment

by:Reza Rad
ID: 33558617
tell us more about your package?
what is input columns and what is output columns exactly?
also samples of inputs and output....

0
 
LVL 30

Expert Comment

by:Reza Rad
ID: 33558792
this is obvious that you should use Script Component Asynchronously, because you should load data first and make output rows as you want,
this is my article about asynchronous script component:
http://www.experts-exchange.com/A_2886-How-to-use-Script-Component-as-Asynchronous-Transformation.html

and also you should use Split function in script task to split input value based on ( / ) character,
string[] inputarray=Row.InputCol.Split("/");

and then loop through this inputarray and add new rows.

but for detailed help, and exact code for your problem, you should provide information I requested in first post.


0
 
LVL 16

Accepted Solution

by:
vdr1620 earned 2000 total points
ID: 33567389
You can add a derived column and check if the string is of that pattern using a FINDString Function and then map them Accordingly in your destination

In the derived Column you can use the below expression

Expr 1:
FINDSTRING(ColumnName,"/",1)>0 ? SUBSTRING(ColumnName,1,FINDSTRING(ColumnName,"/",1)-1) : ColumnName

Expr 2:
FINDSTRING(ColumnName,"/",1)>0 ? SUBSTRING(ColumnName,FINDSTRING(ColumnName,"/",1)+1,LEN(ColumnName)) : ''

Expr1 will have the String1 value and Exp2 will have String 2 value, if the pattern is string1/string2 ..Else Expr 1 will have string Value and Expr2 will have Null Value..You can map these two to the destination columns

You can also use Conditional split to search for the pattern and Split, then use derived column to process the data that meets the criteria or else directly send them to destination
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

636 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