Udostępnij za pośrednictwem


Server Class

The Server object represents an instance of Microsoft SQL Server.

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

Syntax

'Declaration
Public NotInheritable Class Server
    Inherits SqlSmoObject
public sealed class Server : SqlSmoObject
public ref class Server sealed : public SqlSmoObject
public final class Server extends SqlSmoObject
public final class Server extends SqlSmoObject

Remarks

Updated text:

Updated text:

This namespace, class, or member is supported only in version 2.0 of the Microsoft .NET Framework.

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.

Inheritance Hierarchy

System.Object
   Microsoft.SqlServer.Management.Smo.SmoObjectBase
     Microsoft.SqlServer.Management.Smo.SqlSmoObject
      Microsoft.SqlServer.Management.Smo.Server

Example

How to: Connect to the Local Instance of SQL Server by Using Windows Authentication in Visual Basic .NET

Thread Safety

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.

Platforms

Development Platforms

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

Target Platforms

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

See Also

Reference

Server Members
Microsoft.SqlServer.Management.Smo Namespace

Other Resources

Connecting to an Instance of SQL Server
Disconnecting from an Instance of SQL Server
Managing Servers

Change History

Release

History

New content:
  • Added text to the ConnectionContext Remarks section.

Changed content:
  • Removed the database mirroring disclaimer from the Endponts property of the Server class.

  • Removed the database mirroring disclaimer from the EnumDatabaseMirrorWitnessRoles method of the Server class.

Release

History

New content:
  • Added to the description of the Server class Remarks section.

  • Added code samples to the Server class members in the Example section.

  • Added to the description of the Server class members in the Remarks section.