Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Passing a variable to a table

Author  Topic 

andypgill
Starting Member

34 Posts

Posted - 2013-02-13 : 10:47:06
Hi All

I'm importing a number of tables with SSIS. I have a variable Filename used to select each individual file.

I want to copy the value of this variable to a SQL table FilesImported each time a file is selected.

I've added an execute SQL Task in the for loop container with the code

INSERT INTO
dbo.FilesImported
SELECT
+ @[User::FileName]

This isn't copying the value of the variable to the table.

Any help would be appreciated.

tm
Posting Yak Master

160 Posts

Posted - 2013-02-13 : 13:29:53
Here is one option ..

SSIS - SQL Task >>

In Execute SQL Task Editor
General - SQLStatement ..

Code..

DECLARE @Fname varchar(50)

SET @Fname = ? -- filename passed to variable

INSERT INTO dbo.FilesImported
SELECT @Fname



In Execute SQL Task Editor >>
Parameter Mapping ..

Add >>
Variable Name = User::FileName
Direction = Input
Data Type = VARCHAR
Parameter Name = 0
Parameter Size = -1





Go to Top of Page
   

- Advertisement -