[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

String Concat - An easy one!

Monty

3/25/2007 4:45:00 AM

OK, it must be late at night.... why am I getting the error "Incorrect
syntax near '+'." on this line:

RAISERROR(' blah ' + ' blah ')

TIA...


4 Answers

Tibor Karaszi

3/25/2007 7:56:00 AM

0

> RAISERROR(' blah ' + ' blah ')

You are missing severity level and state. But I assume it was only an example. You cannot do
concatenation, call functions etc for the 1:st parameter. Do it in a variable and use the variable
as the first parameter.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/d...
http://sqlblog.com/blogs/tib...


"Monty" <monty@community.nospam> wrote in message news:e3r2ThpbHHA.4552@TK2MSFTNGP05.phx.gbl...
> OK, it must be late at night.... why am I getting the error "Incorrect syntax near '+'." on this
> line:
>
> RAISERROR(' blah ' + ' blah ')
>
> TIA...
>

Uri Dimant

3/25/2007 9:21:00 AM

0

Monty
Please read about RAISERROR command in the BOL.





"Monty" <monty@community.nospam> wrote in message
news:e3r2ThpbHHA.4552@TK2MSFTNGP05.phx.gbl...
> OK, it must be late at night.... why am I getting the error "Incorrect
> syntax near '+'." on this line:
>
> RAISERROR(' blah ' + ' blah ')
>
> TIA...
>


Stefan

3/25/2007 8:24:00 PM

0

Think printf:

raiserror('%s%s', 0, 1, 'blah1', 'blah2')

--
Cheers,
Stefan Delmarco

http://www.f...



changliw

3/26/2007 3:37:00 AM

0

Hi, Monty,
The concatenation by using '+' is not supported in RAISERROR.
SQL Server BOL says that:
msg_str is a user-defined message with formatting similar to the printf
function in the C standard library.

I am not sure if you know the printf function in C language. '+' cannot be
used in printf function to add two string (pointers).
Stefan's sample best demonstrate a workaround for this issue:
raiserror('%s%s', 0, 1, 'blah1', 'blah2')

If you have any other questions or concerns, please feel free to let us
know.

Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.


Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/de....
======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================