共用方式為


Server.InstanceName 屬性

Gets the instance name of the instance of SQL Server.

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

語法

'宣告
<SfcPropertyAttribute(SfcPropertyFlags.None Or SfcPropertyFlags.Standalone Or SfcPropertyFlags.SqlAzureDatabase)> _
Public ReadOnly Property InstanceName As String 
    Get
'用途
Dim instance As Server 
Dim value As String 

value = instance.InstanceName
[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Standalone|SfcPropertyFlags.SqlAzureDatabase)]
public string InstanceName { get; }
[SfcPropertyAttribute(SfcPropertyFlags::None|SfcPropertyFlags::Standalone|SfcPropertyFlags::SqlAzureDatabase)]
public:
property String^ InstanceName {
    String^ get ();
}
[<SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Standalone|SfcPropertyFlags.SqlAzureDatabase)>]
member InstanceName : string
function get InstanceName () : String

屬性值

型別:System.String
A String value that specifies the instance name of the instance of SQL Server.

備註

The InstanceName property specifies the name of the instance of SQL Server. This is usually the computer name but it may be a named instance that was specified during setup. InstanceName will return an empty string for the default instance.

範例

C#

Console.WriteLine(srv.InstanceName)

PowerShell

Write-Host $srv.InstanceName

請參閱

參考

Server 類別

Microsoft.SqlServer.Management.Smo 命名空間

其他資源

設定屬性

管理伺服器