Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

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)]
public string InstanceName { 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

Community Additions

ADD
Show:
© 2015 Microsoft