Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to execute this sql task in SSIS package which send an email when the file name is not found. I have declared this user-defined variable "@PackageStartTime" in my ssis package. But when my SSIS package hit this task it fails with following error.

"Executing query DECLARE @PackageStartTime Varchar(250) SET @Packag...." failed with the error.: "Parameter name is unrecognized." Possible failure
reasons: Problem with the query, "ResultSet" Property not set correctly, parameters not set correctly, or connection not established correctly."

SQL
DECLARE @PackageStartTime Varchar(250)
  SET @PackageStartTime =?

  IF(SELECT COUNT(*)
  FROM [dbo].[Table1] WHERE RowCDate >=@PackageStartTime)>0

  BEGIN

  DECLARE @SUB Varchar(250)
  SET @SUB = 'File Failed'+@@SERVERNAME

  DECLARE @BODY Varchar(250)
  SET @BODY = 'File Failed'+@@SERVERNAME

  EXEC msdb.dbo.sp_send_dbmail @profile_name='default',
  @recipients='dev@null.com',
  @subject=@SUB,
  @body=@BODY,
  @query= 'SELECT DISTINCT FileLoadName
  FROM [dbo].[Table1] WHERE RowCDate >=@PackageStartTime',
  @attach_query_result_as_file=1


I am unable to understand. I have just added a variable User::strPackageStartTime as Datatype = String and Value is blank. I don't have that variable in parameter mapping in Execute SQL Task Editor. Is there I am missing something?

Thank in advance
Posted
Updated 13-Mar-13 20:48pm
v3
Comments
Anurag Sinha V 12-Mar-13 0:12am    
Hi,
What does your column RowCDate denote?Is it a DateTime column? If yes, then I guess you need to set your user defined variable @PackageStartTime as DateTime.
Try it....Everything apart from this looks fine in your code.

Hope it helps..

regards
anurag

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900