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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 raise error w/LOG

Author  Topic 

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2005-12-01 : 12:02:06
Need help with the syntax of RAISE ERROR
I would like to have the message recorded in the sql server logs and return the error to the calling application

Please note, I work for a university... this is not a student project


declare @UNDERGRADUATE_STUDENT as int
select @UNDERGRADUATE_STUDENT = isnull(@UNDERGRADUATE_STUDENT, 0)

if @UNDERGRADUATE_STUDENT = 0
RAISERROR ('The ''UNDERGRADUATE_STUDENT'' Web Template does not exist or its description has changed. Use EMS Client Application to resolve this issue', 19, 1)


Server: Msg 2754, Level 16, State 1, Line 5
Error severity levels greater than 18 can only be specified by members of the sysadmin role, using the WITH LOG option.


Tried
RAISERROR ('The ''UNDERGRADUATE_STUDENT'' Web Template does not exist or its description has changed. Use EMS Client Application to resolve this issue', 19, 1, WITH LOG)

Returned

Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'WITH'.



You can do anything at www.zombo.com

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-12-01 : 12:40:30
If the creater of procedure (or the executor of a script) is someone not of sysAdmin fixed server role then severity level can not be greater than 18.

WITH LOG option can be specified with any severity level and the syntax would be:
raiserror ('<msg>', 18, 1) with log

Be One with the Optimizer
TG
Go to Top of Page

clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2005-12-01 : 12:59:08
Thank you!!!
;)

You can do anything at www.zombo.com
Go to Top of Page
   

- Advertisement -