?
Solved

Concatenation of a String to a declared variable

Posted on 2003-03-06
6
Medium Priority
?
928 Views
Last Modified: 2012-08-13
I am trying the following code:

EXEC master..xp_sendmail
     @recipients =  @Email,
     @subject = 'Your Coupon has been Accepted',
     @message = 'Your Profile has been updated with the Coupon ID# ' + @CouponNum

Where @CouponNum is the variable I am trying to make dynamic but I keep getting an error about the plus sign. So how do I assign a variable using string + variable concatenation
0
Comment
Question by:DrDre
6 Comments
 
LVL 4

Expert Comment

by:CRagsdell
ID: 8086225
Try & instead of +

CR
0
 

Author Comment

by:DrDre
ID: 8086238
Tried & still getting a syntax error
0
 
LVL 13

Accepted Solution

by:
ispaleny earned 300 total points
ID: 8086317
declare @message varchar(200)
set     @message = 'Your Profile has been updated with the Coupon ID# ' + @CouponNum
EXEC master..xp_sendmail
    @recipients =  @Email,
    @subject = 'Your Coupon has been Accepted',
    @message = @message
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:DrDre
ID: 8086342
Thank you, it work like a charm
0
 
LVL 11

Expert Comment

by:Nitin Sontakke
ID: 8086524
If you are happy with ispaleny's comment, please accept them as answer and close this thread.
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 8090694
Here to help. Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question