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


how to pass variable to oledb source


how to pass variable to oledb source

Author
Message
Nomvula
Nomvula
SSC Veteran
SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)

Group: General Forum Members
Points: 296 Visits: 636
hi guys
i've created sql task with the following query 'SELECT MAX(wwo.StatusChangedOn) AS MaxDate
FROM wrkWorkOrders AS wwo where wwo.Description = 'Completed Costing' and set up Result Set: Result Name = MaxDate, Variable Name = User::MaxDate.
i want to join Data flow task add and on the oledb source write a select statement to select * from wrkWorkOrders where StatusChangeOn <= MAX(wwo.StatusChangedOn) from the result set.

please help
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18237 Visits: 20398
Nomvula (12/20/2013)
hi guys
i've created sql task with the following query 'SELECT MAX(wwo.StatusChangedOn) AS MaxDate
FROM wrkWorkOrders AS wwo where wwo.Description = 'Completed Costing' and set up Result Set: Result Name = MaxDate, Variable Name = User::MaxDate.
i want to join Data flow task add and on the oledb source write a select statement to select * from wrkWorkOrders where StatusChangeOn <= MAX(wwo.StatusChangedOn) from the result set.

please help


Why not write this as a single query in an OLEDB Source component? Are your data sources different?


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.
Nomvula
Nomvula
SSC Veteran
SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)

Group: General Forum Members
Points: 296 Visits: 636
i'm going to create different sources but on each i need to select values withing the date range variable i'm declaring in the beginning.
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18237 Visits: 20398
Nomvula (12/20/2013)
i'm going to create different sources but on each i need to select values withing the date range variable i'm declaring in the beginning.


Easy enough - just use start and end date parameters for the source queries.


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.
Nomvula
Nomvula
SSC Veteran
SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)SSC Veteran (296 reputation)

Group: General Forum Members
Points: 296 Visits: 636
i don't think i understand, in the execute sql task i created the command SELECT MAX(wwoq.StatusChangedOn) AS MaxDate
FROM wrkWorkOrders AS wwo
INNER JOIN dbo.wrkWorkOrderQueue AS wwoq ON wwo.WorkOrderQueueId = wwoq.Id
INNER JOIN dbo.wrkWorkOrderStatuses AS wwos ON wwo.WorkOrderStatusId = wwos.Id
WHERE wwos.Description = 'Completed - Costing'

then set the Result set to variable User::MaxDate

now i want use the oledb source to select * from table where ChangedOn <= User::MaxDate, but i'm not sure how to do that
Nevyn
Nevyn
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1506 Visits: 3149
Hi nomvula.

You need to set up an expression on your data flow task. it will let you dynamically set the SQL Command for your OLE DB source.

So, properties for the data flow, add expression, SQL command type, then put in a formula to build your query using the variable you build. Remember though, you are building a string with the query in it, not parameterizing the query, so your formula will be outputting the variable into a string and appending that string into your query. Format it accordingly.

Generally I design the whole data flow first with its own SQL command hard coded, then add the expression at the end.
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