Solved

Use SSIS variables as column in sql table

Posted on 2007-04-07
2
1,186 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 13

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

747 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

13 Experts available now in Live!

Get 1:1 Help Now