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

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

Steve2106
Posting Yak Master

United Kingdom
166 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 @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 = @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,



Steve

mfemenel
Professor Frink

USA
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.

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

bklr
Flowing Fount of Yak Knowledge

India
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  
 New 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.05 seconds. Powered By: Snitz Forums 2000