?
Solved

Use SSIS variables as column in sql table

Posted on 2007-04-07
2
Medium Priority
?
1,195 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
[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 Comments
 
LVL 16

Accepted Solution

by:
Megan Brooks earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

764 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