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

x
?
Solved

Append a column to flat file source

Posted on 2009-03-30
6
Medium Priority
?
317 Views
Last Modified: 2013-11-10
Ok, I don't know if I have the most accurate Title for this question, but here goes:

I have a flat file (tab delimited) containing address updates that needs to go to a SQL database.

So, I went ahead and created a Flat File Source and mapped the columns to a OLE DB Data Flow Destination.

Now, in addition to all the colmns in the flat file, say I wanted to map some "static" values to the destination colmns, how would I accomplish this?

For example, I have a column called "Update Source" in the destination table. How would I insert a value in this column if it doesn't exist in the source file without having to create a new column in the source file?
0
Comment
Question by:IUAATech
[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
  • 2
  • 2
6 Comments
 
LVL 5

Assisted Solution

by:catherinelouise
catherinelouise earned 800 total points
ID: 24021736
II would first import the flat file data into a "holding table" - this can be a permanant or a temporary table in the database.  

I would then use the 'Execute SQL Task' tool in SSIS to carry out an insert into the final destination, and at the same time it would be possible to set another column to a specific value.  E.g.

INSERT INTO FinalTable (Col1, Col2, Col3, Col4)
SELECT (Col1, Col2, Col3, 'FIXEDVALUE') FROM HoldingTable
0
 

Author Comment

by:IUAATech
ID: 24021786
That sounds like a lot of work :-)

Wonder if it's possible to use the "OLE DB Command" data flow transformation.
0
 

Author Comment

by:IUAATech
ID: 24021867
Thanks for the suggestion. I will try it out.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Expert Comment

by:catherinelouise
ID: 24021949
It really isn't too much work - although I don't deny there may be a smarter way of doing this!

If you import your file into a new table once using the import wizard that will create your 'holding table' for you - from there your SSIS package should:

1. Execute a SQL task that truncates the holding table (assuming you are running this package multiple times)

2. Import your flat file into the holding table (a similar step to the one you described in your question which will map source to destination)

3. Carry out an Insert into your final table from your holding table as I described above




0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 1200 total points
ID: 24025047
You can do this in SSIS by using a Dervied Column transformation. This transformation sits in your data flow and adds columns. The new columns may be based on existing columns or variables, or it may be a constant like what you're after.
It just depends on whether you want to do the work in the ETL tool or in the database. I am currently weaning myself off doing work in the database so I can decide whether its really worth the effort of doing all the work in the ETL tool.
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 24025055
For more info on this task, open up the SQL Server help file from the start menu and paste this URL in it:
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/sqltut9/html/16389f8a-0484-4c07-ae73-067b30f11e2d.htm
 
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

597 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