Execl資料匯入SQL Server,execl資料匯入sql

來源:互聯網
上載者:User

Execl資料匯入SQL Server,execl資料匯入sql

將execl表格 資料匯入進資料庫 可以指定列 也可以 *
注意:該語句只能在本機資料庫執行 如果串連的是遠程伺服器 應到該伺服器上執行語句

設定伺服器全域配置 啟用Ad Hoc Distributed Queries
該組件存在 安全隱患 所以預設是關閉

exec sp_configure 'show advanced options',1reconfigureexec sp_configure 'Ad Hoc Distributed Queries',1reconfigure

可以匯入execl表格中指定列 到指定表中指定列

insert into 表名(欄位名)     select  欄位名(跟上面對應)from OpenDataSource('Microsoft.Ace.OLEDB.12.0','Data Source="c:\文檔名.xls";Extended properties="Excel 12.0;HDR=Yes"')...[文檔表名$]  go 

設定伺服器全域配置 關閉Ad Hoc Distributed Queries

exec sp_configure 'Ad Hoc Distributed Queries',0reconfigureexec sp_configure 'show advanced options',0reconfigure

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.