Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Using SQL command from variable in Data flow task Expand / Collapse
Author
Message
Posted Thursday, December 17, 2009 8:39 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, February 27, 2012 9:21 AM
Points: 10, 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!
Post #835726
Posted Friday, December 18, 2009 2:30 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, September 30, 2014 3:20 PM
Points: 115, Visits: 747
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.
Post #836185
Posted Thursday, December 5, 2013 12:20 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, April 7, 2014 6:43 AM
Points: 35, 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
Post #1520292
Posted Thursday, December 5, 2013 10:53 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 12:04 AM
Points: 5,255, Visits: 12,180
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1520413
Posted Thursday, December 5, 2013 10:54 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 12:04 AM
Points: 5,255, Visits: 12,180
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.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1520414
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse