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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 RAISERROR

Author  Topic 

zaidqis
Yak Posting Veteran

63 Posts

Posted - 2006-06-14 : 07:41:16
hi
RAISERROR is used to return message to the caller.
how to contain RAISERROR :
variable
declare @name varchar(50)
and string
'Welcome'
i want to contain the RAISERROR messege 'Welcome' + @name value in the same time
ex
Welcome Zaid
can give the code to do this
thank you

mr_mist
Grunnio

1870 Posts

Posted - 2006-06-14 : 07:49:19
declare @message varchar (10)
set @message = 'Hello %s'
declare @yourname varchar (10)
set @yourname = 'me'
raiserror (@message ,10,1, @yourname)


Be aware though that the general usage designed for this statement is not to say hi to the person running the code, but to generate error messages.

You might be better off with PRINT, although admittedly RAISERROR has the benefit of being flushed immediately.

-------
Moo. :)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-14 : 08:52:15
http://www.sommarskog.se/error-handling-I.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

zaidqis
Yak Posting Veteran

63 Posts

Posted - 2006-06-14 : 14:25:22
thank you all for answer me
quote:
set @message = 'Hello %s'

why you put %s after Hello ??
thank you
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2006-06-15 : 04:16:56
It's a formatted string parameter for substitution with the argument.

Read the RAISERROR section in books online.

-------
Moo. :)
Go to Top of Page
   

- Advertisement -