資料庫跨庫查詢SQL

2021-06-07 19:31:02 字數 1003 閱讀 4413

資料庫跨庫查詢sql

select * from opendatasource('sqloledb','data source=****;user id=**;password=******').jshh.dbo.rs_employee

where code = '0110' 

資料庫跨庫查詢功能開啟sp_configure

sp_configure 'show advanced options', 1;

goreconfigure;

gosp_configure 'ole automation procedures', 1;

goreconfigure;

gosp_configure 'ad hoc distributed queries', 1;

goreconfigurego

add: select * into temp1 from 

opendatasource('microsoft.ace.oledb.12.0','data source="c:\1.xlsx";extended properties="excel 12.0;hdr=yes"')...sheet1$

go注釋:從1.xlsx**中選取全部錄入到temp1表中

insert into intranet.dbo.news(newstype,top_flag,itemdate,newstitle,author,newscontent,photo,albumid,documentid,staticurl)

select top 10 newstype,top_flag,itemdate,newstitle,author,newscontent,photo,albumid,documentid,staticurl from opendatasource('sqloledb','data source=****;user id=**;password=******').intranet.dbo.news order by itemdate desc

SQL跨資料庫查詢

語句 select from 資料庫a.dbo.表a a,資料庫b.dbo.表b b wherea.field b.field dbo 可以省略 如 select from 資料庫a.表a a,資料庫b.表b bwhere a.field b.field sqlserver資料庫 這句是對映乙個遠端...

跨資料庫引擎 資料庫查詢

包含訪問 ole db 資料來源中的遠端資料所需的全部連線資訊。當訪問鏈結伺服器中的表時,這種方法是一種替代方法,並且是一種使用 ole db 連線並訪問遠端資料的一次性的 特殊的方法。可以在查詢的 from 子句中像引用表名那樣引用 openrowset 函式。依據 ole db 提供程式的能力,...

sql跨庫查詢

方式一 使用連線伺服器 sp addlinkedserver mylink sqloledb local sp addlinkedsrvlogin mylink false null,sa sa select from mylink test.dbo.student 或者在 物件資源管理器 伺服器物...