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.

 All Forums
 SQL Server 2012 Forums
 SSIS and Import/Export (2012)
 SSIS: select count(*) results in email, error

Author  Topic 

mgreen84
Yak Posting Veteran

94 Posts

Posted - 2014-06-24 : 11:03:30
Im trying to create a package that runs a script and gets the count of records on a table and then have that emailed to me daily.

however I keep receiving a error about the datatype(shouldn't a COUNT return INT datatype?). My sql task result variable(sg_agt_m1_Count)is set as int32. and then in my email task I'm creating a expression for the 'MessageSource' with the following:



"Postgres Table Import Quality Assurance Daily Statistics "+ Replace((DT_WSTR,15)(DT_DBDATE) DATEADD( "d", -0, GETDATE())," ","") + "

CMSForte Load Stats " + "
------------------------

" +" Table "+"
CMSForte.dbo.sg_agt_m1 :"



however I'm receiving the following error:


"The data types "DT_WSTR" and "DT_14" are incompatible for binary operator "+". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a operator.

Attempt to set the result type of binary operation ""Postgres Table Import Quality Assurance Daily Statistics " + REPLACE((DT_WSTR,15)(DT_DBDATE)DATEADD("d",-0,GETDATE())," ",'')+"
CMSForte Load Stats"+"
-----------------------
"+" Table "+"
CMSForte.dbo.sg_agt_m1 :"+ @[User::sg_agt_m1_Count]" failed with error code 0xC0047080.


Any help would be much appreciated

tm
Posting Yak Master

160 Posts

Posted - 2014-07-24 : 13:10:27
This is an old post but thought to add what may be generating the error.

Since @[User::sg_agt_m1_Count] is defined as int32, this needs to be converted to string

Example:
"Postgres....." + (DT_WSTR, 12)@[User::sg_agt_m1_Count]
Go to Top of Page
   

- Advertisement -