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 |
Steve2106
Posting Yak Master
183 Posts |
Posted - 2009-02-24 : 09:37:08
|
Hi Guys,I have been battleing with XP_SMTP_SendMail and I am winning to some extent. The last piece of the jigsaw is being able to show in the message/body the relevant data pulled from the database. I am having trouble concatenating the data together. This is part of what I am using: DECLARE @rc int DECLARE @body VARCHAR(1024) DECLARE @ID int DECLARE @Desc varchar(50) DECLARE @PCompDate varchar(50) DECLARE @FName varchar(50) DECLARE @LName varchar(50) DECLARE @ActioneeEmail varchar(100)I then do my select statement etc. Everything works great the job fires and I receive the emails if I use: Set @body = @Descbut when I try: Set @body = 'Action : ' + @ID + 'Desc : ' + @Desc + 'Needs to be initialized'The job fails. I don't receive anything.How do I concatenate these bits of data together so they can be sent in the body of the email.Thanks for any help you can give.Best Regards,Steve |
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2009-02-24 : 09:53:44
|
It's probably failing because you're trying to concatenate a string 'Action' to an integer @ID. Try casting or converting your @ID to a varchar (or char if it's fixed length). Instead of doing this from your mail procedure try just doing this in query analyzer until you get to the point where @body can be output as a string, then you know you have the bugs worked out.Mike"oh, that monkey is going to pay" |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-24 : 23:22:18
|
convert(varchar(32),@id) use this inplace of @idand rememeber use isnull or coalesce function when concatenating the variable to avoid nulls |
|
|
|
|
|