I am trying to run a stored procedure from an SQL task:
First, here is the proc (execs fine in : SSMS query)
CREATE PROC [dbo].[sp_Hist_Max_Dates]
@.Interval varchar(8),
@.Name1 varchar(32),
@.Max_Date datetime OUTPUT
AS
IF @.Interval = 'd'
BEGIN
SELECT @.Max_Date = MAX(Max_Daily_Date) FROM SiteTable WHERE Site_Name = @.Name1
END
ELSE IF @.Interval = 'm'
BEGIN
SELECT @.Max_Date = MAX(Max_Monthly_Date) FROM SIteTable WHERE SIte_Name = @.Name1
END
Here is the call from the Execute SQL Task:
EXEC sp_Hist_Max_Dates ?, ?, ? OUTPUT
Here are how the parameters are defined in the Execute SQL Task:
gv_VarInterval INPUT varchar 0
gv_Name1 INPUT varchar 1
gv_MaxDate OUTPUT datetime 2
(Variables used as input parameters defined as strings with package scope)
Here is the error I am getting:
[Execute SQL Task] Error: Executing the query "EXEC dbo.sp_Hist_Max_Dates ?, ?, ? OUTPUT" failed with the following error: "Error HRESULT E_FAIL has been returned from a call to a COM component.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
The connection is just OLEDB to SQL Server 2005. Any ideas why is this not working?
Thanks!
Kayda
Try adding the parameter name (as declared in the SP) and the '=' sign to the SQL command:
EXEC sp_Hist_Max_Dates @.Parametername1 = ?,@.Parametername2= ?, @.Parametername3 = ? OUTPUT
|||another cryptic error message? hardly surprising... check if the account under which a package is run, has rights to execute the stored procedure|||On your SQL Task, set the "BypassPrepare" to TRUE. Otherwise the validation tries to validate the ?'s, and can't.
No comments:
Post a Comment