Access the database on a different computer (just as long as you join the net)

xiaoxiao2021-03-05  52

- Access databases on different computers (remote only as long as join)

- If you regularly access or large data volume, it is recommended to use a link server.

- Create a link server EXEC SP_ADDLINKEDSERVER 'SRV_LNK', '', 'SQLOLEDB', 'Remote Server Name, or IP Address' Exec Sp_addlinkedsrvlogin' SRV_LNK ',' FALSE ', NULL,' User Name, 'Password' Go

- Query example Select * from srv_lnk. Database name .dbo. Table name

- Import example selection * INTO table from srv_lnk. Database name. Dbo. Table name

Go - to remove the link server exec sp_dropserver 'srv_lnk', 'Droplogins' when it is no longer used in the future.

- If it is just a temporary access, you can directly use the OpenrowSet - query example Select * from openrowset ('sqloledb', 'sql server name'; 'username'; 'password', database name .dbo. Database

- Import example selection * into table from OpenRowSet ('sqloledb', 'SQL server name ";' username

转载请注明原文地址:https://www.9cbs.com/read-36605.html

New Post(0)