Solved

Use SSIS variables as column in sql table

Posted on 2007-04-07
2
1,189 Views
Last Modified: 2013-11-30
I want to use the value of one of my SSIS variables as a column in a table I'm importing.  Basically, I have 36 files that I'm importing from Excel into a SQL table.  I want one of the columns in my sql table to have the filename in it.  Can someone help me out with this?
Jim
0
Comment
Question by:JLEmlet
2 Comments
 
LVL 14

Accepted Solution

by:
Megan Brooks earned 500 total points
ID: 18874064
Two ways to do it would be using a derived column transformation or a script task. Either way, the transformation must be inserted between the data source and destination.

Derived column transformations are described in http://msdn2.microsoft.com/en-us/library/ms137630.aspx . Values are taken from expressions, which can include variables. In this case the expression would consist only of the variable, and is easily created in the expression editor.

I have usually used script tasks instead of derived column transformations because I usually need to include changing derived values such as identity values that start with a value taken from a variable and then increment for each row.

New columns are added to script tasks on the Inputs and Outputs tab, as I recall (I don't have access to BIDS at the moment). The 'inputs' portion lists the inputs to the script task, while 'outputs' lists columns outputs added by the task. Once you have added the column, you will need to add the appropriate variable name to the read-only variables list on the Script tab. Then within the script you can access the value through the Dts.Variables collection and assign it to the appropriate column. Some information can be found at http://msdn2.microsoft.com/en-us/library/ms136127.aspx .

If all you need to do is add a value taken from a column, the derived column transformation shoud be easier to add. Again, this is all from memory but I will be back in a place where I can run BIDS in the morning, if you need more information.
0
 

Author Comment

by:JLEmlet
ID: 18888873
thanks, that did the trick.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

816 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

8 Experts available now in Live!

Get 1:1 Help Now