sp_dropmessage (Transact-SQL)sp_dropmessage (Transact-SQL)

適用於: 是SQL Server 否Azure SQL Database 否Azure SQL 資料倉儲 否平行處理資料倉儲 APPLIES TO: yesSQL Server noAzure SQL Database noAzure SQL Data Warehouse noParallel Data Warehouse

SQL Server Database EngineSQL Server Database Engine 執行個體中,卸除指定的使用者自訂錯誤訊息。Drops a specified user-defined error message from an instance of the SQL Server Database EngineSQL Server Database Engine. 可以使用來檢視使用者自訂訊息sys.messages目錄檢視。User-defined messages can be viewed using the sys.messages catalog view.

主題連結圖示 Transact-SQL 語法慣例Topic link icon Transact-SQL Syntax Conventions

語法Syntax

  
sp_dropmessage [ @msgnum = ] message_number  
    [ , [ @lang = ] 'language' ]  

引數Arguments

[ @msgnum = ] message_number 是要卸除的訊息編號。[ @msgnum = ] message_number Is the message number to drop. message_number必須是訊息編號大於 50000 的使用者定義的訊息。message_number must be a user-defined message that has a message number greater than 50000. message_numberint,預設值是 NULL。message_number is int, with a default of NULL.

[ @lang = ] 'language' 是要卸除之訊息的語言。[ @lang = ] 'language' Is the language of the message to drop. 如果所有指定的所有語言版本message_number會卸除。If all is specified, all language versions of message_number are dropped. 語言sysname,預設值是 NULL。language is sysname, with a default of NULL.

傳回碼值Return Code Values

0 (成功) 或 1 (失敗)0 (success) or 1 (failure)

結果集Result Sets

無。None.

PermissionsPermissions

需要的成員資格sysadminserveradmin固定伺服器角色。Requires membership in the sysadmin and serveradmin fixed server roles.

備註Remarks

除非所有指定語言、 所有當地語系化的訊息版本必須先卸除之前美國卸除訊息的英文版。Unless all is specified for language, all localized versions of a message must be dropped before the U.S. English version of the message can be dropped.

範例Examples

A.A. 卸除使用者自訂訊息Dropping a user-defined message

下列範例會卸除使用者定義的訊息,而數字50001,從sys.messagesThe following example drops a user-defined message, number 50001, from sys.messages.

USE master;  
GO  
EXEC sp_dropmessage 50001;  

B.B. 卸除包括當地語系化版本的使用者自訂訊息Dropping a user-defined message that includes a localized version

下列範例會卸除包括訊息當地語系化版本的使用者自訂訊息 (編號 60000)。The following example drops a user-defined message, number 60000, that includes a localized version of the message.

USE master;  
GO  
  
-- Create a user-defined message in U.S. English  
EXEC sp_addmessage   
    @msgnum = 60000,  
    @severity = 16,  
    @msgtext = N'The item named %s already exists in %s.',   
    @lang = 'us_english';  
  
-- Create a localized version of the same message.  
EXEC sp_addmessage   
    @msgnum = 60000,  
    @severity = 16,  
    @msgtext = N'L''élément nommé %1! existe déjà dans %2!',  
    @lang = 'French';  
GO  
  
-- This statement will fail as long as the localized version  
-- of the message exists.  
EXEC sp_dropmessage 60000;  
GO  
  
-- This statement will drop the message.  
EXEC sp_dropmessage  
    @msgnum = 60000,  
    @lang = 'all';  
GO  

C.C. 卸除使用者自訂訊息的當地語系化版本Dropping a localized version of a user-defined message

下列範例會卸除使用者自訂訊息 (編號 60000) 的當地語系化版本,但不會卸除整個訊息。The following example drops a localized version of a user-defined message, number 60000, without dropping the whole message.

USE master;  
GO  
  
-- Create a user-defined message in U.S. English  
EXEC sp_addmessage   
    @msgnum = 60000,  
    @severity = 16,  
    @msgtext = N'The item named %s already exists in %s.',   
    @lang = 'us_english';  
  
-- Create a localized version of the same message.  
EXEC sp_addmessage   
    @msgnum = 60000,  
    @severity = 16,  
    @msgtext = N'L''élément nommé %1! existe déjà dans %2!',  
    @lang = 'French';  
GO  
-- This statement will remove only the localized version of the   
-- message.  
EXEC sp_dropmessage  
    @msgnum = 60000,  
    @lang = 'French';  
GO  

另請參閱See Also

RAISERROR (Transact-SQL) RAISERROR (Transact-SQL)
sp_addmessage (Transact-SQL) sp_addmessage (Transact-SQL)
sp_altermessage (-SQL)) sp_altermessage (Transact-SQL)
FORMATMESSAGE (Transact-SQL) FORMATMESSAGE (Transact-SQL)
sys.messages (Transact-SQL) sys.messages (Transact-SQL)
系統預存程序 (Transact-SQL)System Stored Procedures (Transact-SQL)