Solved

Append a column to flat file source

Posted on 2009-03-30
6
304 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 5

Assisted Solution

by:catherinelouise
catherinelouise earned 200 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 300 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Exceptions 3 37
Help with SQL Server Stoplist 2 18
Sql Query with datetime 3 12
Changing the datatype of a column from nvarchar to date 47 12
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

910 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

25 Experts available now in Live!

Get 1:1 Help Now