Server.InstanceName Server.InstanceName Server.InstanceName Property

Definition

Gets the instance name of the instance of SQL Server.

public:
 property System::String ^ InstanceName { System::String ^ get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcProperty(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.Standalone | Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcPropertyFlags.SqlAzureDatabase)]
public string InstanceName { get; }
Public ReadOnly Property InstanceName As String
Property Value

A String value that specifies the instance name of the instance of SQL Server.

Examples

C#

Console.WriteLine(srv.InstanceName)  

PowerShell

Write-Host $srv.InstanceName  

Remarks

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.

Applies to