July 24, 2008 at 9:26 am
Original Script
SET ANSI_WARNINGS OFF
SELECT '==========' + CHAR(13) + ISNULL(CONVERT(VARCHAR(10),MAX(TxDate ),120),'') AS TransDate ,+ CHAR(10) + SPACE(5) ,+
+ CHAR(13)+ 'RunDate' + CHAR(13) + '==========' + CHAR(13) + ISNULL(CONVERT(VARCHAR(10),MAX(RunDate),120),'') FROM TEST
SET ANSI_WARNINGS ON
Built into query
SET ANSI_WARNINGS OFF
EXEC msdb..SP_SEND_DBMAIL
@Recipients = 'rmahlangu@africanbank.co.za'
,@Subject = 'Succesfull Load '
,@Query = 'SELECT ''========== + CHAR(13)
+ ISNULL(CONVERT(VARCHAR(10),MAX(TxDate ),120),'') AS TransDate
,+ CHAR(10) + SPACE(5) ,+
+ CHAR(13)+ ''RunDate' + 'CHAR(13) + ''=========='
+ 'CHAR(13) + ISNULL(CONVERT(VARCHAR(10),MAX(RunDate),120),'') FROM TEST'
SET ANSI_WARNINGS ON
ERROR MESSAGE
Msg 102, Level 15, State 1, Line 7
Incorrect syntax near '+'.
July 24, 2008 at 9:41 am
Declare a varchar variable, assign the query to that, then use that in the parameter. It doesn't like building the query string in the parameter.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
July 25, 2008 at 1:30 am
Thanks got it right and it works with the variable.....
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply