Link to home
Create AccountLog in
Avatar of coventri
coventri

asked on

Passing Variables To OLEDB Source in SSIS

Hi,
How can I pass variables in select clause in oledb source  and I am using sql command as data access mode.I am able to pass variables in where clause
I enclosed SSIS Package which I am using.In package i am creating a text file.The text file contains Header,detail Record,Trailer.check the data flow task(flat file generation) in my package

In header row .I have phone number column(804-217-7396).I want to pass it as variable @phone_number.
can any one help me

Thanks,
coventri
SSIS-packge.txt
PSP-Rate.txt
Avatar of PedroCGD
PedroCGD
Flag of Portugal image

Coventri,
Explain better where is your issue.
I opened your project, but I dont have the database scripts to generate database  in my PC.
Regards,
Pedro
www.pedrocgd.blogspot.com
Avatar of stelth240
I think I know what you're looking for but I'm not 100% sure.  If you want to replace the literal phone number in the package (804-217-7310 in the attachment) with a variable from SSIS, you should be able to just put the ? placeholder in place of the phone number and add another parameter pointing to an SSIS variable containing the phone number.

If you want to have the phone number pulled from a data source, that's not possible because the select statement in the beginning of the source component is not pulling data from any source itself.  I don't think this is what you want though.

Try the first suggestion and see what happens.  I would try keeping the single quotes in, and then removing them if that doesn't work.  It should be able to replace the placeholder correctly.  I'm going to try it on my end as well.
ASKER CERTIFIED SOLUTION
Avatar of stelth240
stelth240
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Sorry, I wrote the wrong variable name.  The top portion of the command should be:

"select 'HD'+'NEW YORK PRESCRIPTION SAVER'+space(3)+'BETH NGUYEN'+space(21)+ '" + @[User::phone_number] + "' +space(8)+convert(varchar(8), getdate(), 112) as [HEADER]"

And I tried it with single quote and it works correctly.