Server.InstanceName Property

 

Gets the instance name of the instance of SQL Server.

Namespace:   Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

[<SfcPropertyAttribute(SfcPropertyFlags.None | SfcPropertyFlags.Standalone | SfcPropertyFlags.SqlAzureDatabase)>]
member InstanceName : string with get

Property Value

Type: 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
Return to top
Show: