A recently developed query system is basically on other servers. Therefore, a local server is designed to store data from a remote server!
One way is to use OpenDataSource to remotely read data!
Select *
From OpenDataSource (
' Sqloledb ' ,
' Data Source = servername; user id = myuid; Password = mypass '
). Northwind. DBO. Categories
However, the remote server cannot be confirmed, which is troublesome. If you want to implement it, you can only save the connection information to the server through dynamic SQL (Exec or sp_excute_ SQL)
Another method is to add a linked server, Sp_addmediaserver @ Server = N 'Linked server name ' ,
@ Srvproduct = N ' ' ,
@ Provider = N ' Sqloledb ' ,
@ Datasrc = N 'Remote Server IP Address ' ,
Add linked server login Sp_add1_srvlogin [ @ Rmtsrvname = ] 'Linked server name '
[ , [@ Useself = ] 'False' ' ]
[ , [@ Locallogin = ] 'Local Login Name ' ]
[ , [@ Rmtuser = ] 'Remote Login Name ' ]
[ , [@ Rmtpassword = ] 'Remote Password ' ]
In this way, the remote server can be accessed through SQLSelect * FromLink server name. Remote Data name. Remote owner. Remote table name
You do not need to worry about the login name of the remote server address. You can only link to the server name, which remains unchanged. You cannot change the name of the remote server address when it is officially released.Program!