Home » Microsoft » 70-765 » Which argument in sp_addmessage should you configure?
A Microsoft SQL Server instance has a database named Employees. The database contains information about employees including their salary.
You must create a custom system message as an alert when an error is raised.
You need to create the custom message in the sys.messages table.
Which argument in sp_addmessage should you configure?
A. @with_log
B. @lang
C. @severity
D. @replace
Correct Answer: C
Explanation/Reference:
The following example adds a custom message to sys.messages.
USE master;
GO
EXEC sp_addmessage 50001, 16, N’Percentage expects a value between 20 and 100.
Please reexecute with a more appropriate value.’;
GO
Syntax: sp_addmessage [ @msgnum= ] msg_id , [ @severity= ] severity , [ @msgtext= ] ‘msg’ [ , [ @lang= ] ‘language’ ]
[ , [ @with_log= ] { ‘TRUE’ | ‘FALSE’ } ]
[ , [ @replace= ] ‘replace’ ]
References: https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addmessage-transact-sql?view=sql-server-2017
The answer is D not C.
The @replace parameter will enable to have a custom message. Below is the explaination from the link itself :
[ \@severity = ]severity Is the severity level of the error. severity is smallint with a default of NULL. Valid levels are from 1 through 25.
[ \@replace = ] ‘replace’ If specified as the string replace, an existing error message is overwritten with new message text and severity level. replace is varchar(7) with a default of NULL. This option must be specified if msg_id already exists. If you replace a U.S. English message, the severity level is replaced for all messages in all other languages that have the same msg_id.