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();
By specifying SQL Server as the product name, data is accessed on the linked server by using the SQL Server Client OLE DB Provider, which is the official OLE DB provider for SQL Server.
No comments:
Post a Comment