Let your SQL statement cross-server cross-table execution across database

xiaoxiao2021-03-05  21

the first method:

Select * from OpenDataSource ('sqloledb', 'data source = remote IP; user ID = sa; password = password'). Database name .dbo. Table name

Second method: First use the coupling server: exec sp_addlinkedserver 'alias', '', 'msdasql', null, null, 'driver = {SQL Server}; server = remote name; UID = user; PWD = password;' Exec Sp_addlinkedsrvlogin @ rmtsrvname = 'alias', @ useseelf = 'false', @ locallogin = 'sa', @ rmtuser = 'sa', @ rmtpassword = 'password' Go can then you can follow: select * from alias. library name. DBO. Table name INSERT library name .dbo. Table name Select * from alias. Table name .dbo. Table name Select * INTO library name. dbo. New table name from alias. Database name. dbo. Table name Go

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

New Post(0)