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.SetRemotePassword("PASSWORD");
login.Impersonate = false;
lsrv.ProductName = "SQL Server";
lsrv.Create();
login.Create();
My name is Robert Kanasz and I have been working with ASP.NET, WinForms and C# for several years.
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
MCPD - ASP.NET Developer 3.5
- Web Developer 4
MCITP - Database Administrator 2008
- Database Developer 2008
Open source projects:
DBScripter - Library for scripting SQL Server database objects
Please, do not forget vote