Click here to Skip to main content
13,865,706 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


22 bookmarked
Posted 13 Nov 2010
Licenced CPOL

SQL Server - How to create LinkedServer using SMO

, 13 Nov 2010
Rate this:
Please Sign up or sign in to vote.
LinkedServer allows you to access resources in the other resources. Consider, you have a server named "ServerA" and you would like to grab some data from the remote server named "ServerB". In that case, you need to create a linked server. In our scenario, the linked server is "ServerB".

The linked servers communicate using an OLE DB connection. These connections handle the commands between the linked servers, so coders and administrators can query data and tables without knowing the intricacies of database communication.

Here is the code example that shows how to create LinkedServer using SMO:

Server srv = new Server(@"INSTANCEA");
LinkedServer lsrv = new LinkedServer(srv, "INSTANCEB"); 
LinkedServerLogin login = new LinkedServerLogin();
login.Parent = lsrv;
login.Name = "LOGIN_ON_INSTANCEA";
login.RemoteUser = "LOGIN_ON_INSTANCEB";
login.Impersonate = false;
lsrv.ProductName = "SQL Server";


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kanasz Robert
Architect The Staffing Edge & Marwin Cassovia Soft
Slovakia Slovakia
My name is Robert Kanasz and I have been working with ASP.NET, WinForms and C# for several years.
MCSD - Web Applications
MCSE - Data Platform
MCPD - ASP.NET Developer 3.5
- Web Developer 4
MCITP - Database Administrator 2008
- Database Developer 2008
MCSA - SQL Server 2012
MCTS - .NET Framework 3.5, ASP.NET Applications
- SQL Server 2008, Database Development
- SQL Server 2008, Implementation and Maintenance
- .NET Framework 4, Data Access
- .NET Framework 4, Service Communication Applications
- .NET Framework 4, Web Applications
MS - Programming in HTML5 with JavaScript and CSS3 Specialist

Open source projects: DBScripter - Library for scripting SQL Server database objects

Please, do not forget vote

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
MahendraChawhan14-Oct-12 5:05
professionalMahendraChawhan14-Oct-12 5:05 
GeneralRe: My vote of 5 Pin
Kanasz Robert16-Oct-12 4:38
memberKanasz Robert16-Oct-12 4:38 
GeneralIt requires ALTER ANY LINKED SERVER permission. Pin
Kanasz Robert30-Nov-10 3:59
memberKanasz Robert30-Nov-10 3:59 
GeneralReason for my vote of 5 Good tip. What are the necessary use... Pin
sjelen30-Nov-10 2:52
professionalsjelen30-Nov-10 2:52 
GeneralReason for my vote of 5 Thanks for sharing this tip. Pin
linuxjr28-Nov-10 13:37
professionallinuxjr28-Nov-10 13:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 13 Nov 2010
Article Copyright 2010 by Kanasz Robert
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid