Click to Rate and Give Feedback

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (4)
Other versions are also available for the following:
Server Class

The Server object represents an instance of SQL Server.

Namespace: Microsoft.SqlServer.Management.Smo
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
Visual Basic (Declaration)
<PhysicalFacetAttribute> _
<RootFacetAttribute(GetType(Server))> _
<EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)> _
Public NotInheritable Class Server
    Inherits SqlSmoObject
    Implements IAlterable, IScriptable, IServerSettings, IServerInformation, _
    IDmfFacet, IAlienRoot
C#
[PhysicalFacetAttribute] 
[RootFacetAttribute(typeof(Server))] 
[EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)] 
public sealed class Server : SqlSmoObject, IAlterable, IScriptable, IServerSettings, 
    IServerInformation, IDmfFacet, IAlienRoot
C++
[PhysicalFacetAttribute] 
[RootFacetAttribute(typeof(Server))] 
[EvaluationModeAttribute(AutomatedPolicyEvaluationMode::CheckOnSchedule)] 
public ref class Server sealed : public SqlSmoObject, IAlterable, IScriptable, IServerSettings, 
    IServerInformation, IDmfFacet, IAlienRoot
J#
/** @attribute PhysicalFacetAttribute() */ 
/** @attribute RootFacetAttribute(Microsoft.SqlServer.Management.Smo.Server) */ 
/** @attribute EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule) */ 
public final class Server extends SqlSmoObject implements IAlterable, IScriptable, 
    IServerSettings, IServerInformation, IDmfFacet, IAlienRoot
JScript
PhysicalFacetAttribute 
RootFacetAttribute(Microsoft.SqlServer.Management.Smo.Server) 
EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule) 
public final class Server extends SqlSmoObject implements IAlterable, IScriptable, 
    IServerSettings, IServerInformation, IDmfFacet, IAlienRoot

The Server class represents an instance of SQL Server. In SMO programming, the Server object determines the connection to a physical SQL Server installation. The Server class is the highest level in the SMO instance object hierarchy. When a Server object variable is created, it establishes a connection to an instance of SQL Server. If you do not specify the name in the Server class constructor, the connection is always made with the local, default instance of SQL Server.

By using the Server object, you can do the following:

  • Connect to an instance of SQL Server.

  • Modify the connection settings.

  • Run Transact-SQL statements directly.

  • Capture Transact-SQL output from the SMO program.

  • Manage transactions.

  • View operating system information.

  • Modify and view SQL Server settings, information, and user options.

  • Modify and view SQL Server configuration options.

  • Register the instance of SQL Server in the Active Directory directory service.

  • Subscribe to and handle SQL Server events.

  • Reference databases, endpoints, credentials, logins, linked servers, system messages, DDL triggers, system data types, and user-defined messages.

  • Regenerate the service master key.

  • Detach and attach databases.

  • Stop processes or databases.

  • Grant, deny, or revoke permissions on the database.

  • Enumerate information about the server.

  • Read the error log.

  • Remove the backup history.

  • Get and set the default initialization fields for specified types.

  • Create endpoints, such as database mirroring endpoint.

To get Server object properties, users can be a member of the public fixed server role.

To set Server object properties, users must be a member of the sysadmin fixed server role.


System.Object
   Microsoft.SqlServer.Management.Smo.SmoObjectBase
     Microsoft.SqlServer.Management.Smo.SqlSmoObject
      Microsoft.SqlServer.Management.Smo.Server
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server.

Target Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Retrieve a Microsoft.SQLServer.Management.SMO.Server object using PowerShell      Richard Vantrease   |   Edit   |   Show History
  

#-------------------------------------------------------------------------

# ScriptName : get-SQLServer.ps1 # # Purpose : Returns a Microsoft.SQLServer.Management.SMO.Server # object, or displays the properties for the object if the # -Display switch is used.

#
# Dependencies : Microsoft.SQLServer.SMO
#-------------------------------------------------------------------------

param

(

[string]$ServerName,

[switch]$Display

)

#-------------------------Environment Preferences-------------------------

Set-PSDebug -strict

#-------------------------------------------------------------------------

# Load Microsoft.SQLServer.SMO Library

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") |out-null


$SQLServer = new-object "Microsoft.SQLServer.Management.SMO.Server" $ServerName

if($Display){ $SQLServer.ConnectionContext }

else{ $SQLServer }

Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker