關於T sql匯入匯出Excel

2021-05-04 09:51:44 字數 1032 閱讀 1098

我的伺服器上

use test

insert into openrowset('microsoft.jet.oledb.4.0'

,'excel 8.0;hdr=yes;database=c:/a.xls',sheet1$)

select * from a

客戶的伺服器上

use test

delete from a

insert into a select distinct * from openrowset('microsoft.jet.oledb.4.0'

,'excel 8.0;hdr=yes;database=c:/a.xls',sheet1$)

在執行的過程中會出現錯誤:

「sql server 阻止了對元件 'ad hoc distributed queries' 的 statement'openrowset/opendatasource' 的訪問,因為此元件已作為此伺服器安全配置的一部分而被關閉。系統管理員可以通過使用 sp_configure 啟用 'ad hoc distributed queries'。有關啟用 'ad hoc distributed queries' 的詳細資訊」

解決方法:開啟ad hoc distributed queries:

「exec sp_configure 'show advanced options', 1

go reconfigure

go exec sp_configure 'ad hoc distributed queries', 1

go reconfigure

go 」

使用完成後,關閉ad hoc distributed queries:

「exec sp_configure 'show advanced options', 0

go reconfigure

go exec sp_configure 'ad hoc distributed queries', 0

go reconfigure

go 」

關於匯入 匯出Excel檔案

因為excel的易用,使得使用者能夠自己做表,幾乎所有使用者的報表都有excel檔案。使用者希望能將excel的檔案讀入報表工具,這樣就可以省去畫表的工作了 同時,生成的報表,要能匯出成excel檔案,這樣使用者就可以在其上再加工處理。因而對於乙個報表工具來說,有沒有完善的匯入 匯出excel檔案的...

關於excel的匯入匯出

目前為方便操作,很多系統都增加了批量匯入匯出的功能。檔案匯入匯出一般的格式都是excel,現將常用設計用例總結如下 批量匯入 1 模板只有乙個檔案 模板只有乙個檔案時,比較簡單,檢查一下模板和預期是否一致即可。2 模板是乙個壓縮包 模板是壓縮包時,需要檢查一下壓縮包檔案是否齊全,每乙個檔案和預期是否...

excel匯入匯出

匯出 yii框架中 header content disposition attachment filename 123.xls arr connection createcommand select from recruit queryall array this db get recruit r...