Server.LinkedServers Server.LinkedServers Server.LinkedServers Property

Definition

Represents a collection of LinkedServer objects. Each LinkedServer object represents a linked server registered on the instance of SQL Server.

public:
 property Microsoft::SqlServer::Management::Smo::LinkedServerCollection ^ LinkedServers { Microsoft::SqlServer::Management::Smo::LinkedServerCollection ^ get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObject(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerRelationship.ObjectContainer, Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerCardinality.ZeroToAny, typeof(Microsoft.SqlServer.Management.Smo.LinkedServer))]
public Microsoft.SqlServer.Management.Smo.LinkedServerCollection LinkedServers { get; }
Public ReadOnly Property LinkedServers As LinkedServerCollection
Property Value

A LinkedServerCollection object that represents all the linked servers registered on the instance of SQL Server.

Examples

Visual Basic

'Connect to the local, default instance of SQL Server.  
Dim srv As Server  
srv = New Server  
'Display the linked servers.  
Dim lksv As LinkedServer  
For Each lksv In srv.LinkedServers  
   Console.WriteLine(lksv.Name)  

Next

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")  
foreach ($lksv in $srv.LinkedServers)  
{  
   Write-Host $lksv.Name  
}  

Remarks

The LinkedServers property points to the LinkedServerCollection object. You can use the collection to reference the linked servers registered on the instance of SQL Server.

Applies to