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.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

United Kingdom
183 Posts

Posted - 02/24/2009 :  09:37:08  Show Profile  Reply with Quote
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 - 02/24/2009 :  09:53:44  Show Profile  Visit mfemenel's Homepage  Reply with Quote
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

Flowing Fount of Yak Knowledge

1693 Posts

Posted - 02/24/2009 :  23:22:18  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000