SSIS 2017 "Execute SQL Task" fails Could not find stored procedure - sql

I'am using SSIS with an ADO.NET connection to Azure. Within SSIS I want to execute a procedure with one input and 2 output parameters. The input parameter is a static value. The Procedure works with T-SQL within SSMS.
I setup the "Execute SQL Task" as followed
General
SQLStatement: METRICE_VAULT.GP_1001_GENERIC_PRE_PROCESS 2, #INSTANCE, #PROCESS_STATUS
IsQueryStoredProcedure: True
ConnectionType: ADO.NET
ResultSet: None
SQLSourceType: Direct input
Parameter Mapping
When I execute the "Execute SQL Task" I received the following error
Must declare the scalar variable "#". Possible failure reason: Problem with the query, "ResultSet" property not set correctly..
Update
After adding parameters name i am receiving the following error:
Execute SQL Task] Error: Executing the query "METRICE_VAULT.GP_1001_GENERIC_PRE_PROCESS 2, #INS..." failed with the following error: "Could not find stored procedure 'METRICE_VAULT.GP_1001_GENERIC_PRE_PROCESS 2, #INSTANCE ,#PROCESS_STATUS'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Below is the way to configure your parameters and properties. Set IsQueryStoredProcedure property to True and instead of writing exec ProcName you just have to give ProcName in sqlstatment if you are using ADO.NET Connection.

Change the direction of your parameters to INPUT.

Since you are using ADO.NET You must specify the parameter name. As example:
METRICE_VAULT.GP_1001_GENERIC_PRE_PROCESS 2,#param1, #param2
And don't use parameter index in parameter mapping tab as shown in the screenshot.
Additional Information
You can refer to the following official documentation for more details and examples:
Map Query Parameters to Variables in an Execute SQL Task
Update 1
Try using a fully qualified name:
<database name>.<schema name>.<stored procedure name>
Or add a USE <database> command before the stored procedure execution.

Related

Error when run EXEC procedure in T-SQL Statement Task

I created few procedures that I want to run using Maintenance Plan's Execute T-SQL Statement Task box however I'm getting error that job is not found.
Maintenance Task's configuration:
Returned error for running EXEC [dbo].[sp_backup_full] N'db_name', N'path/where//to/store/backup':
End Progress Error: 2021-06-29 18:59:00.42 Code: 0xC002F210 Source: full_backup_and_delete_old_one Execute SQL Task
Description: Executing the query "EXEC [dbo].[sp_backup_full] N'db_name..." failed with the following error: "Could not find stored procedure 'dbo.sp_backup_full'.".
Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
If you dont specify the databasename, by default, it is run in the master database. You can give three part name for the stored procedure call, to make sure that it is using the right database for execution.
EXEC [DatabaseName].[dbo].[sp_backup_full]

SSIS Generic Error for SP Execution

In a for each loop container , for each job reference.
I am running an execute sql task to get a list of 21 INPUT parameters from my stored procedure ( Task 1 ). The INPUT parameters
are then stored in SSIS variables.
Then I have an execute sql task to run the stored procedure, where I set the 21 Input Paramters and an Output parameter. ( Task 2 )
When running the package it fails at Task 2 with the following generic error:
Error: 0xC002F210 at Run sp_insert_Package, Execute SQL Task:
Executing the query "DECLARE #TestFaultStageID int DECLARE #TestID..."
failed with the following error: "Multiple-step OLE DB operation
generated errors. Check each OLE DB status value, if available. No
work was done.". Possible failure reasons: Problems with the query,
"ResultSet" property not set correctly, parameters not set correctly,
or connection not established correctly. Task failed: Run
sp_insert_Fault2 Error: 0xC002F210 at Run sp_insert_Package, Execute
SQL Task: Executing the query "DECLARE #TestFaultStageID int DECLARE
#StoreID..." failed with the following error: "Multiple-step OLE DB
operation generated errors. Check each OLE DB status value, if
available. No work was done.". Possible failure reasons: Problems with
the query, "ResultSet" property not set correctly, parameters not set
correctly, or connection not established correctly. Task failed: Run
sp_insert_Fault2 Warning: 0x80019002 at 02-01-02-Epoch-Jobs-Load: SSIS
Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method
succeeded, but the number of errors raised (2) 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.
I have tried to find the error, by checking all the data types and conversions and other stuff but no luck so far. Is there an easy way to track down or narrow down cause ?
Sql Server 2012
In Execute SQL Task component, in SQLStatement field, you should have question marks (?) set in place where you want to put parameters. They should also be defined in Parameter mapping tab.
Are you sure those are set correctly? Could you share your SQLStatement field value?
Sorted ? missing for the OUTPUT parameter was the problem. Sorry All ! Arghhhh

Execute SQL Task Failing

I have this issue with my Execute SQL Task Failing. I am trying to execute a sp using an execute sql task. The execute statement is contained in a variable (exec [sp_name] par1, par2) that I have declared at the package level. Now inside the exec sql tak, I am calling this variable. Now when I try to execute this task, it fails and I get the following:
[Execute SQL Task] Error: Executing the query "EXEC CTL_ISRT_A 55,1" failed with the following error:
"Could not find stored procedure 'CTL_ISRT_A'.". Possible failure reasons: Problems with the query,
"ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
There is a stored procedure called "CTL_ISRT_A" in the db and I am able to execute it from SQL Server. This sp is inserting a new row in the table and it returns ##IDENTITY. Basically I need to store an integer value after the insert happens to a variable.
I tried setting the result set to a 'Single Row' and tried assigning the value to a variable but it didn't help. Could someone help me here?
Thanks in advance
I got a fix to this. Modified the stored procedure code and it began to work.

SSIS Stored Procedure Call

I'm trying to call a simple stored procedure which would return a list of names in normal test format, all in a single line. I'm passing it two parameters, but no matter how i setup the call, either within a OLE DB Source Editor, or within an execute SQL task.
There must be something i'm missing with my SQL statement b/c i keep getting an error.
My SQL command text is
EXEC [dbo].[spGetEmployerIdCSV] ?, ?
The parameters I'm passing are listed exactly as they are declared in the stored procedure, #IDType and #IDNumber, which are mapped to predefined variables.
Every time I try to run it from either task type, I get a
The EXEC SQL construct or statement is not supported.
What is the best way to run a stored procedure within SSIS?
Thank you.
I cannot recreate your issue.
I created a control flow with the proc already in existence.
I have my execute sql task configured as
My parameters tab shows
When I click run, the package goes green.
My initial assumption was that you had signaled that you were using a stored procedure and were erroneously providing the EXEC part. I had done something similar with SSRS but even updating the IsQueryStoredProcedure to True, via Expression, I could not regenerate your error message.
If you are doing something else/different/in addition to what I have shown in the Execute SQL Task, could you amend your question to describe what all functionality the procedure should show.
Did you specify output parameters?
For 2 in / 1 out your SQL code will look like:
EXEC [dbo].[spGetEmployerIdCSV] ?, ?, ? OUTPUT
ResultSet has to be set to none!
I had the same problem.
When you execute the task check the 'Progress' tab; this will give you a 'fully fledged' error details.
In my case I didn't map the parameter which I created in the SQL Task to the actual one in the Stored Procedure.
So, double click the SQL Task, click on Parameter Mapping on the left hand side, then Create the parameters and their respective mappings. Here is a screenshot (in version 2012):
I faced with a similar issue after upgrading to SSDT for VS 2013 (the problem was with lookup element).
Fixed by using this answer:
EXEC ('dbo.MyStoredProcedure')
WITH RESULT SETS
(
(
MyIntegerColumn INT NOT NULL,
MyTextColumn VARCHAR(50) NULL,
MyOtherColumn BIT NULL
)
)
use the same command you use to run the stored procedure in MySQL workbench
call ();
USE this command in Execute SQL Task

Execute SQL Task on SSIS 2005. ADO.NET connection type and Stored Procedure Input Parameter. Not working. Syntax error

I am Execute SQL Task on SSIS 2005. ADO.NET connection type and Stored Procedure Input Parameter. Not working. Syntax error
I read some documentation and blogs but its not working for me. This is what I have on SQL Statement of the Exeute sql task (ADO.NET)
EXEC StoredProcedureName #ParameterName =
It gives different errors on different syntax I tried. All failture
Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
I tried all combination like EXEC StoredProcedureName #ParameterName = ?
StoredProcedureName ?
StoredProcedureName #ParameterName = ?
etc etc in vain
I checked the parameter type and its fine
The same setup works if I change the connection type to OLE DB. But I don't want OLE DB and want to change it to ADO.NET
I tried as per Microsoft specification but that also didn't work
per Micrtosoft
If IsQueryStoredProcedure is set to False, EXEC uspGetBillOfMaterials #StartProductID, #CheckDate
I tried changing all combinations on IsQueryStoredProcedure property also in vain
I mapped parameter name,order and variable on Parameter mappings properly still no luck
as i said it works with OLEDB but does not work with ADO.NET even after changing syntax.
Please help
I have another task on ADO.NET and it works fine because it has no input parameter
Old question but in case it helps someone :
Set IsQueryStoredProcedure to True
Write ONLY the name of the stored procedure in the SQLStatement : sp_MyStoredProcedure
In the "Mapping" tab, add your parameter :
Direction = input ; Name = #parameterName
Try setting the IsQueryStoredProcedure to False and then setting the SqlStatement to
Execute MyStoredProcedure #MyParameter
Where #MyParameter is the Parameter Name in the Parameter Mapping section of the task, which references a variable in your package. This variable holds the value that you want to pass to the stored procedure.
When using an ADO.NET connection parameters should use the '#' notation, when using OLE DB you should use the '?' notation.
ADO.NET. Execute MyStoredProcedure #MyParameter
OLE DB. Execute MyStoredProcedure ?
Remember though that when using OLE DB, you should reference the Parameter Names (in Parameter Mapping) using 0,1,2,3 etc