I define a package variables "varOutTable" and "varFromTable".
and I insert a SQL Execute SQL Task into Control Flow
my sql command is
"Select * into @.[User::varOutTable] from @.[User::varFromTable]"
but the task failed,
it seems that sql task can't get the varOutTable and varFromTable
How can I use the Variables in SQL Execute SQL task?
thanks!!
Use an expression to build your SQL statement. This is:
Open SQL Task editor|||
thank for your reply.
you are right,
it runs great now.
|||Will this work for a select count(*)?|||agentf1 wrote: Will this work for a select count(*)?
Why not? A select count(*) would work just like a select * does.... So yes, it would work.|||Just make sure you add an alias to the column (eg. Count(*) as MyCount) and the result set uses the same name (MyCount)....|||I am doing this, my SQL looks like Select count(*) as recordcount from table_name. My variable is set up in ResultSet on the task and is an object.|||Are there any examples of doing a select count(*) into a variable? For some reason when displaying my variable it looks like it contains -1.|||
agentf1 wrote: Are there any examples of doing a select count(*) into a variable? For some reason when displaying my variable it looks like it contains -1.
That's because your variable is of OBJECT type. If you're returning one row, one value, you can use an integer data type (in this case).|||I am, thanks. I will try this.|||When changed to int32 I get the following error message.
Error: 0xC001F009 at D3OLNAC3: The type of the value being assigned to variable "User::spmessage" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "select count(*) as recordcount from loan_auj" failed with the following error: "The type of the value being assigned to variable "User::spmessage" 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.
Task failed: Execute SQL Task
Warning: 0x80019002 at D3OLNAC3: The Execution method succeeded, but the number of errors raised (3) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "D3OLNAC3.dtsx" finished: Failure.|||
That should work. Make sure ResultSet property is set to single row; the result set page you have a resultsetname RecordCount that points to a SSIS variable and that variable is Int32.
If all this is fine; then post all the details of you Execute SQL task to see other potential causes of error
|||That was it, I needed to change result set to single row. Thanks.
No comments:
Post a Comment