SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using SQL command from variable in Data flow task


Using SQL command from variable in Data flow task

Author
Message
work.dev
work.dev
Grasshopper
Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)Grasshopper (12 reputation)

Group: General Forum Members
Points: 12 Visits: 52
Hello,
Here is my requirement. I need the ability to use one of the below two queries in my oledb command
Query1: Select a1,b1,c1 from table1
Query1: Select a1,b1,c1 from table2
Note : both tables table1 and table2 have the same schema

I build the query in a script task and populate a user variable. ( gvUserVar)
gvUserVar could either have Query1 or Query2 based on some logic.

Iam using 'SQL command from variable' in OLE Command Source ( in data flow task ) and have set the User::gvUserVar as the variable name.

So far so good.

Now i need to do some transformation of a1,b1,c1 before i move data to a file
Issue: I do not get to see the source columns as output of the OLEDB Command souce. Is this because the query is being built at runtime?
Also if i to transform or work with the column output from 'SQL command from variable' what do i need to do?

Any help is appreciated.
Thanks!
David Data
David Data
Old Hand
Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)Old Hand (353 reputation)

Group: General Forum Members
Points: 353 Visits: 810
Yes, your query is being built at run time, so at design time there's no information to know to show you the columns, which makes it difficult for you to set it up correctly. (You could define the columns manually if you knew what to set.)

Try it with your actual first query, instead of using a variable. When that is set up and working, change it back to use the variable.

In general in SSIS, with anything computed such as a connection name or query string, set it up first with an actual fixed name, then change to use the variable when it's working. That allows SSIS to help you set things up, because it can access the object and know its characteristics.
Debbie BG
Debbie BG
SSC Rookie
SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)SSC Rookie (37 reputation)

Group: General Forum Members
Points: 37 Visits: 53
I tried this with my actual query and the output file was correct. I then switched back to using my variable and received an error. The objects and characteristics of the columns are not available any more.
I am using VS2008
Phil Parkin
Phil Parkin
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19510 Visits: 20462
At what point did you receive the error? (Run time or design time.)

Have you made any modifications to the DelayValidation property?


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Phil Parkin
Phil Parkin
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19510 Visits: 20462
Also, setting the default (design-time) value of the variable to be a valid query may help you get over this hurdle.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search