Solved

SSIS: Loading in a flat data file, parsing, sending data to SQL tables

Posted on 2010-08-25
12
725 Views
Last Modified: 2013-11-10
I'm loading in a flat file with varying number of columns, but now I want to take the data, parse it out and upload it to SQL tables. Not sure how to build this. Anyone have any links with examples I could follow?

Thanks!!
0
Comment
Question by:wppiexperts
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 12

Expert Comment

by:mcv22
ID: 33526075
To apply changes to existing data, you need to use derived column transformations along with the data flow task. More info here: http://msdn.microsoft.com/en-us/library/ms137630.aspx and here : http://www.ssistalk.com/2007/01/23/derived-column/
0
 
LVL 12

Expert Comment

by:mcv22
ID: 33526115
0
 
LVL 16

Expert Comment

by:vdr1620
ID: 33526146
0
 
LVL 22

Expert Comment

by:8080_Diver
ID: 33526254
I generally import the data into a staging table that has only VarChar columns.  That lets me deal with squirrelly data as well as creating INSERTs to move the data where I please after it is scrubbed.
0
 
LVL 30

Expert Comment

by:Reza Rad
ID: 33527868
when you want to import dynamic data into sql server, BCP is one of the best options. look at samples of BCP here:
http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/

0
 

Author Comment

by:wppiexperts
ID: 33531231
vdr1620: the link you posted about pulling in csv files with varying columns was exactly what I was looking for. At this point now that the data is loading, I'm trying to figure out how to push subsets of that data into a sql table.

For example, a row may contain a customer number, an item ID and then data pertaining to hourly use of that item, so I'd be splitting that row into 3 tables. Its at this point I'm not sure how to process that data, do I use tools within SSIS to do this or program it all in a script task.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 22

Expert Comment

by:8080_Diver
ID: 33531311
wppiexperts,
Are you loading the data into a staging table or are you trying to do this on the fly, so to speak?
If you are using a staging table, then all you have to do is figure out waht columns go in which tables and create queries (or stored procs) to accomplish that.  You can then include those, via Execute SQL Tasks, in your SSIS package.
If you are doing it on the fly, then you are probably using a FOR EACH loop and handling the data RBAR (Row By Agonizing Row), which is absolutely THE worst way to do it, and you would still be using Execute SQL Tasks to accomplich the actual work.
0
 
LVL 16

Expert Comment

by:vdr1620
ID: 33531390
So, According to what you have said.. You have a Flat File Source and Script task connected... You will need a MultiCast Transformation and then 3 OLE DB destinations one for each tables..Connect the green Arrow from Multicast to each of the destinations and map the required column accordingly
0
 

Author Comment

by:wppiexperts
ID: 33532981
came across this article which expands a bit on the link provided by vdr1620:
http://sqlblog.com/blogs/andy_leonard/archive/2010/05/18/ssis-design-pattern-loading-variable-length-rows.aspx

so, now on to multicast!
0
 
LVL 16

Expert Comment

by:vdr1620
ID: 33533211
Thats a nice Reference and might be suitable to what you are trying to do by avoiding multi task transformation as i suggested before..you can just create Multiple Outputs using Script task and map them to OLE DB Destinations directly
0
 

Author Comment

by:wppiexperts
ID: 33577850
OK - so I'm at the point where I have transformed the flat file data and I can load it into the sql tables. My next task is to take anwhere from 24-50 columns from the flat file and pivot them into rows of data. What tool in SSIS would be best suited for that....again...anyone have examples they can point me to?
0
 
LVL 16

Accepted Solution

by:
vdr1620 earned 500 total points
ID: 33577982
You can use Pivot transformation ..Example is in the link below

http://www.bimonkey.com/2009/06/the-pivot-transformation/

You also have pivot in SQL ..SSIS Vs SQL pivot is compared in below link

http://bennyaustin.wordpress.com/2010/06/26/ssis-pivot-transform-vs-t-sql-pivot/
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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.
Viewers will learn how the fundamental information of how to create a table.

758 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

19 Experts available now in Live!

Get 1:1 Help Now