共用方式為


LinkedServers Collection

未來的 Microsoft SQL Server 發行版本將不再提供此功能。請避免在新的開發工作中使用此功能,並計劃修改目前使用此功能的應用程式。

The LinkedServers collection contains LinkedServer objects exposing the properties of an OLE DB data source.

顯示目前物件的 SQL-DMO 物件模型

Properties

Count Property

Methods

Add Method

Refresh Method

Item Method

Remove Method (Collections)

備註

Microsoft SQL Server implements persistent storage of an OLE DB provider name and data source definition called a linked server.

With the LinkedServers collection, you can:

  • Create a linked server, usable as a data provider for a distributed query.
  • Remove an OLE DB linked server.

For more information about creating a linked server by using the LinkedServer object and LinkedServers collection, see the LinkedServer Objectsection.

To remove a linked server

  1. Get the LinkedServer object referencing the target linked server from the LinkedServers collection.

  2. Set the DropLogins property of the LinkedServer object to True, or remove all associated linked server login mappings by using the Remove method of the LinkedServerLogins collection.

  3. Use the Remove method of the LinkedServer object to remove the OLE DB data source definition.

When using the Item or Remove method, the LinkedServers collection supports member identification using either name or ordinal reference syntax. For example:

Set oLinkedServer = oSQLServer.LinkedServers("SEATTLE1")

Or:

Set oLinkedServer = oSQLServer.LinkedServers(1)
ms132900.note(zh-tw,SQL.90).gif附註:
Creating or removing OLE DB data source definitions persisted as SQL Server linked servers using the LinkedServers collection requires appropriate privilege. The SQL Server login used for SQLServer object connection must be a member of the fixed role sysadmin.