Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Services / Integration Services / July 2008

Tip: Looking for answers? Try searching our database.

Give Variable value from SQL Select

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pvong - 26 Jul 2008 14:57 GMT
I'm new to SSIS.  I've assigned a variable for Package called "Variable"
with a date time.  I would like to set the value buy pulling from the SQL DB
using a Select Statement.  Can someone tell me where I would do something
like this? The select statement is just a simple one"

Select VarDate from Variables where Veriable = 'Moxy'

Thanks!

phil
matteus - 28 Jul 2008 09:09 GMT
> I'm new to SSIS.  I've assigned a variable for Package called "Variable"
> with a date time.  I would like to set the value buy pulling from the SQL DB
[quoted text clipped - 6 lines]
>
> phil

Hi phil,
You should use Execute SQL task. Once you've created the variable and
you've got the execute sql task in the control flow pane, dblclick on
it and in the general tab:
- set the connection and set the sql statement to the sql (like the
one above),
- set ResultSet to Full result Set
In the Result set tab:
- add a new row, and change the resultName frm NewResultName to 0 and
on the righe set the VariableName to the variable you created (should
be something like User::YourVariable).
With these settings your execute sql task will put its result set into
the variable set in the result set pane.

Hope this helps
M.
pvong - 28 Jul 2008 16:42 GMT
I did as you as you said and I got this error message.

[Execute SQL Task] Error: Executing the query "SELECT     VarDate FROM
Variables WHERE     (Variable = 'Moxy')" failed with the following error:
"The type of the value being assigned to variable "User::VarDate" differs
from the current variable type. Variables may not change type during
execution. Variable types are strict, except for variables of type Object.
". Possible failure reasons: Problems with the query, "ResultSet" property
not set correctly, parameters not set correctly, or connection not
established correctly.

I checked my DB and that column is set to DateTime and my variable (VarDate)
is set to DateTime also.

Please help.
Thanks!
Phil

>> I'm new to SSIS.  I've assigned a variable for Package called "Variable"
>> with a date time.  I would like to set the value buy pulling from the SQL
[quoted text clipped - 24 lines]
> Hope this helps
> M.
matteus - 29 Jul 2008 11:23 GMT
> I did as you as you said and I got this error message.
>
[quoted text clipped - 13 lines]
> Thanks!
> Phil

Thought i've already answered...

Sorry I gave you a wrong clue.
The Result Set Type should be set to Single Row, instead of Full
Result Set.
Try that and let us know.

Check the BOL as well, paragraph "Populating a Variable with a Result
Set" at:
http://technet.microsoft.com/en-us/library/ms141003.aspx

Bye,
M.
pvong - 29 Jul 2008 14:03 GMT
M - That did work for me, but I have some other questions.  Seems like you
know a lot about SSIS.  I was wondering if I could get your outside email to
ask you a couple of other questions if you don't mind.  Some of it contain
personal data that I don't want to put into a newsgroup.

This is only if you want me to contact you.  Please email me at
phillipvong*at*gmail*dot*com

Thanks!
Phil

>> I did as you as you said and I got this error message.
>>
[quoted text clipped - 30 lines]
> Bye,
> M.
matteus - 30 Jul 2008 08:35 GMT
Phil, i'm glad it worked.
I'm not the only one here and there're people here that knows a lot
more than me, that's why you should rely on the ng.
If it contains some personal data, change it to foo and/or rename
tables/columns to generic names, etc.
Same for users, domains...

M.

> M - That did work for me, but I have some other questions.  Seems like you
> know a lot about SSIS.  I was wondering if I could get your outside email to
[quoted text clipped - 6 lines]
> Thanks!
> Phil
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.