Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)

Author  Topic 

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 @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 = @Desc

but 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,


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.

"oh, that monkey is going to pay"
Go to Top of Page

Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-24 : 23:22:18
convert(varchar(32),@id) use this inplace of @id
and rememeber use isnull or coalesce function when concatenating the variable to avoid nulls
Go to Top of Page

- Advertisement -