Operating data between the database * / - create linked server Exec the sp_addlinkedserver ' ITSV ' , ' ' , ' the SQLOLEDB ' , ' remote server name or ip address ' Exec sp_addlinkedsrvlogin ' ITSV ' , ' false ' , null , ' username ' , ' password ' - a sample query the SELECT * from ITSV name .dbo database table names. - import sample the SELECT * INTO
Table from ITSV name .dbo database table name.
- Delete link server will no longer use the Exec sp_dropserver ' ITSV ' , ' droplogins ' - to connect remote / LAN data (the OPENROWSET / OPENQUERY / the OPENDATASOURCE) - 1, the OPENROWSET - - sample query SELECT * from OPENROWSET ( ' the SQLOLEDB ' , ' SQL server name ' ; ' username ' ; ' password ' , the name of the database table name .dbo.) - Health cost surface SELECT * INTO
Table from OPENROWSET ( ' the SQLOLEDB ' , ' SQL server name ' ; ' username ' ; ' password ' ., .Dbo database table name) - the local tables into a remote table INSERT OPENROWSET ( ' the SQLOLEDB ' , ' SQL Server Name ' ; ' username ' ; ' password ' ., .dbo database table names) SELECT * from the local table - update the local table update B SET . A column B
= A column A.
From OPENROWSET ( ' the SQLOLEDB ' , ' SQL server name ' ; ' username ' ; ' password ' ., The name of the database table name .dbo) AS A Inner the Join local table B ON a.column1 = b.column1 - OPENQUERY usage need to create a connection - first create a connection to create a linked server Exec the sp_addlinkedserver ' ITSV ' , ' ' , ' the SQLOLEDB ' , ' remote server name or ip address
' - Query the SELECT * the FROM OPENQUERY (ITSV, ' the SELECT * .dbo the FROM database table name. ' ) - the local table into the remote table INSERT OPENQUERY (ITSV, ' . .Dbo the SELECT * the FROM database table name ' ) the SELECT * from the local table - update the local table update B SET . column B B = A column B. the fROM OPENQUERY (ITSV, ' the SELECT * .dbo the fROM database table name. ' ) AS A Inner the Join local table B ON
. a Column A = B column A.
- . 3, OPENDATASOURCE / OPENROWSET the SELECT * the FROM OPENDATASOURCE ( ' the SQLOLEDB ' , ' the Data = the Source IP / ServerName; login name of the User ID =; Password = password ' ) .test.dbo.roy_ta
Table from ITSV name .dbo database table name.
- Delete link server will no longer use the Exec sp_dropserver ' ITSV ' , ' droplogins ' - to connect remote / LAN data (the OPENROWSET / OPENQUERY / the OPENDATASOURCE) - 1, the OPENROWSET - - sample query SELECT * from OPENROWSET ( ' the SQLOLEDB ' , ' SQL server name ' ; ' username ' ; ' password ' , the name of the database table name .dbo.) - Health cost surface SELECT * INTO
Table from OPENROWSET ( ' the SQLOLEDB ' , ' SQL server name ' ; ' username ' ; ' password ' ., .Dbo database table name) - the local tables into a remote table INSERT OPENROWSET ( ' the SQLOLEDB ' , ' SQL Server Name ' ; ' username ' ; ' password ' ., .dbo database table names) SELECT * from the local table - update the local table update B SET . A column B
= A column A.
From OPENROWSET ( ' the SQLOLEDB ' , ' SQL server name ' ; ' username ' ; ' password ' ., The name of the database table name .dbo) AS A Inner the Join local table B ON a.column1 = b.column1 - OPENQUERY usage need to create a connection - first create a connection to create a linked server Exec the sp_addlinkedserver ' ITSV ' , ' ' , ' the SQLOLEDB ' , ' remote server name or ip address
' - Query the SELECT * the FROM OPENQUERY (ITSV, ' the SELECT * .dbo the FROM database table name. ' ) - the local table into the remote table INSERT OPENQUERY (ITSV, ' . .Dbo the SELECT * the FROM database table name ' ) the SELECT * from the local table - update the local table update B SET . column B B = A column B. the fROM OPENQUERY (ITSV, ' the SELECT * .dbo the fROM database table name. ' ) AS A Inner the Join local table B ON
. a Column A = B column A.
- . 3, OPENDATASOURCE / OPENROWSET the SELECT * the FROM OPENDATASOURCE ( ' the SQLOLEDB ' , ' the Data = the Source IP / ServerName; login name of the User ID =; Password = password ' ) .test.dbo.roy_ta
Reproduced in: https: //www.cnblogs.com/guoxiaowen/archive/2012/10/17/2727853.html