共用方式為


SystemMessages 屬性

表示 SystemMessage 物件的集合。每個 SystemMessage 物件代表在 SQL Server 執行個體上定義的系統訊息。

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(SystemMessage))> _
Public ReadOnly Property SystemMessages As SystemMessageCollection
    Get
'用途
Dim instance As Server
Dim value As SystemMessageCollection

value = instance.SystemMessages
[SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(SystemMessage))]
public SystemMessageCollection SystemMessages { get; }
[SfcObjectAttribute(SfcContainerRelationship::ObjectContainer, SfcContainerCardinality::ZeroToAny, 
    typeof(SystemMessage))]
public:
property SystemMessageCollection^ SystemMessages {
    SystemMessageCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(SystemMessage))>]
member SystemMessages : SystemMessageCollection
function get SystemMessages () : SystemMessageCollection

屬性值

型別:Microsoft.SqlServer.Management.Smo. . :: . .SystemMessageCollection
SystemMessageCollection 物件,代表在 SQL Server 執行個體上定義的所有系統訊息。

備註

The SystemMessages property points to the SystemMessageCollection object, which references the system messages on the instance of SQL Server. You can use the collection to reference the predefined system messages. Use the UserDefinedMessages property to access user-defined messages.

範例

Visual Basic

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Reference an existing system message using the ItemByIdAndLanguage method.
Dim msg As SystemMessage
msg = srv.SystemMessages.ItemByIdAndLanguage(14126, "us_english")
'Display the message ID and  text.
Console.WriteLine(msg.ID.ToString + " " + msg.Text)

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$msg = $srv.SystemMessages.ItemByIdAndLanguage(14126, "us_english")
Write-Host $msg.ID, $msg.Text