Home > T-SQL > FormatMessage Function for Messengers – SQL Server

FormatMessage Function for Messengers – SQL Server


FORMATMESSAGE(,): It returns the reconstructed SQL Server error message with user input. The reason I use the word reconstructed message here is that formatmessage function takes message string from sys.messages view and replace the parameter with user values in the message.

Implementation:

This query will print a system message of message id (20715) and language id (1033) . It is must to use appropriate language id for the message. This example uses language id (1033) US English.

pic1This error message may appear when it fails to create merge replication triggers. But, using formatmessage() function I am going to print the error message with my object name.

pic2This function introduced the user text in place of %s. But, SQL Server will print this error message with the object name that caused the error.

Advertisements
Categories: T-SQL Tags: , , ,
  1. No comments yet.
  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: