Solved

RAISEERROR not showing error id for user defined errors

Posted on 2011-03-18
4
343 Views
Last Modified: 2012-05-11
Hi,

I have written a procedure and need to raise an userdefinederror msg, I made the statement below

RAISEERROR('Already Implmented',1,1);

I am expecting it throw an error id of 1. However I don't see it. Please let me know what I am missing.

You help with this is greatly appreciated.
0
Comment
Question by:joonugt
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35164722
see the correct sytax of raise error
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 250 total points
ID: 35164737
BEGIN TRY
    -- RAISERROR with severity 11-19 will cause execution to
    -- jump to the CATCH block.
    RAISERROR ('Error raised in TRY block.', -- Message text.
               16, -- Severity.
               1 -- State.
               );
END TRY
BEGIN CATCH
    DECLARE @ErrorMessage NVARCHAR(4000);
    DECLARE @ErrorSeverity INT;
    DECLARE @ErrorState INT;

    SELECT
        @ErrorMessage = ERROR_MESSAGE(),
        @ErrorSeverity = ERROR_SEVERITY(),
        @ErrorState = ERROR_STATE();

    -- Use RAISERROR inside the CATCH block to return error
    -- information about the original error that caused
    -- execution to jump to the CATCH block.
    RAISERROR (@ErrorMessage, -- Message text.
               @ErrorSeverity, -- Severity.
               @ErrorState -- State.
               );
END CATCH;
0
 
LVL 3

Assisted Solution

by:kumarnimavat
kumarnimavat earned 250 total points
ID: 35165219
It is just a typo you've made.

This would work fine
RAISERROR('Already Implmented',1,1);
0
 

Author Closing Comment

by:joonugt
ID: 35497333
none
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now