Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Maina
Starting Member
1 Post |
Posted - 2013-03-11 : 23:51:39
|
0 down vote favorite 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."DECLARE @PackageStartTime Varchar(250)SET @PackageStartTime =?IF(SELECT COUNT(*)FROM [dbo].[Table1] WHERE RowCDate >=@PackageStartTime)>0BEGINDECLARE @SUB Varchar(250)SET @SUB = 'File Failed'+@@SERVERNAMEDECLARE @BODY Varchar(250)SET @BODY = 'File Failed'+@@SERVERNAMEEXEC msdb.dbo.sp_send_dbmail @profile_name='default',@recipients='dev@null.com',@subject=@SUB,@body=@BODY,@query= 'SELECT DISTINCT FileLoadNameFROM [dbo].[Table1] WHERE RowCDate >=@PackageStartTime',@attach_query_result_as_file=1I 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. I am sorry. I am new to this website |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-12 : 00:26:59
|
the easiest way to do this is to create a variable for query (say User::strSQLQuery. Then make evaluate as expression true for it and set expression as"IF(SELECT COUNT(*)FROM [dbo].[Table1] WHERE RowCDate >=@PackageStartTime)>0BEGIN DECLARE @SUB Varchar(250)SET @SUB = 'File Failed'+@@SERVERNAMEDECLARE @BODY Varchar(250)SET @BODY = 'File Failed'+@@SERVERNAMEEXEC msdb.dbo.sp_send_dbmail @profile_name='default',@recipients='dev@null.com',@subject=@SUB,@body=@BODY,@query= 'SELECT DISTINCT FileLoadNameFROM [dbo].[Table1] WHERE RowCDate >= " + @[User::strPackageStartTime] + " ',@attach_query_result_as_file=1"then use this variable inside sql task after making SQLSourceType as variable. You dont need to do any mapping in parameters tab for this------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
|
|
|
|
|
|