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


displaying a query's value in an ssis variable


displaying a query's value in an ssis variable

Author
Message
frdrckmitchell7
frdrckmitchell7
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 295
Hi all you clever people

I have the following query (I suppose it is self-explanatory, but...):

select max(a.TransDateNumeric) as ToDate from BI1_DW_Dim_CalendarDefinition a
join BI1_DW_Dim_SystemParameters b on b.RUN_Type = 'SALES' AND
(B.RUN_PeriodFrom = A.TransPeriod OR B.RUN_PeriodTo = A.TransPeriod)
WHERE A.TransDateSmall < DATEADD(D,-1, GETDATE())
GROUP BY A.TransPeriod

which displays the value: 20131105 (you guessed right - it is yesterday's date as an integer value).

I want to run this query in an ssis variable so that it displays the value (at the moment my value display the query itself).

Any help anyone?
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: General Forum Members
Points: 62748 Visits: 13298
You can run the query in an Execute SQL Task and store the result in a variable.
You can only see the actual value of the variable though when debugging the package.

I'm not sure that's what you want?


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
frdrckmitchell7
frdrckmitchell7
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 295
Hi Koen, thanks for replying.
Not sure how to set up my variable (it's an integer in our database so what would the data type be as a variable?). All the data types I use (except the object data type) gives me an error when I run the Execute SQL Task.

If you have any input please let me know.

Kind regards
Fred
frdrckmitchell7
frdrckmitchell7
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 295
Hi Koen
It actually works when I set it up as an object. I just didn't debug it, so put a Script Task up and it actually displays it as 20131105. I suppose I should cast it to set it as a date when using it later?

Kind regards
Fred
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: General Forum Members
Points: 62748 Visits: 13298
The data type of the variable should be integer.
Make sure you select single row result set in the Execute SQL Task.
If you want it as a date, I would cast it in the SQL query itself.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
frdrckmitchell7
frdrckmitchell7
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 295
Hi Koen

There's no other variable datatype that I use that seem to work other than the object data type.

Will make do with it in the meantime and see where I get stuck.

Thanks for your help though.

Kind regards
Fred
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