Home > Alter, Error Messages, SQL Queries, SQL Server, Stored Procedures, System Stored Procs, T-SQL > Change the system error messages with custom messages

Change the system error messages with custom messages

December 30, 2009 Leave a comment Go to comments

This post discusses about ways to change the system messages with custom messages . This is not widely used, as it is not advisable to change these messages.  However there is nothing wrong in knowing it. :) 

We can change the Custom messages by using system pocs “sp_dropmessage” and “sp_addmessage “. 

I executed a query as given in the picture below. 

After this I used the script below to change the system message. The proc “sp_dropmessage” is used to drop the already existing message and  “sp_addmessage ” to add a new one.  

  

IF EXISTS (SELECT 1 FROM sys.messages WHERE message_id = 100097) BEGIN 

EXEC sp_dropmessage 100097  

END 

GO 

EXEC sp_addmessage @msgnum = 100097, @severity = 16, @msgtext = ‘SP %s : My new text message!’  

 

The message was changed as shown in the picture. 

Now, can we do the same using the script below ? 

update  SYS.MESSAGES 

 set  text = ‘SP %s : My new text message!’ 

 WHERE MESSAGE_ID = 100097 

try it yourself

Advertisements
  1. Ali Qazaq
    March 16, 2013 at 1:31 pm

    thanks a lot.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: