SQL中读取Excel 以及 bpc语言
生活随笔
收集整理的這篇文章主要介紹了
SQL中读取Excel 以及 bpc语言
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1 --開(kāi)啟導(dǎo)入功能
2 exec sp_configure 'show advanced options',1
3 reconfigure
4 exec sp_configure 'Ad Hoc Distributed Queries',1
5 reconfigure
6 --允許在進(jìn)程中使用ACE.OLEDB.12
7 EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
8 --允許動(dòng)態(tài)參數(shù)
9 EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
1 -- 如果不存在表 就是用 SELECT * INTO 表名 ... 2 -- 讀取Excel數(shù)據(jù),注意Excel必須事先關(guān)閉 3 SELECT *into Temp FROM OpenDataSource( 'Microsoft.ACE.OLEDB.12.0','Data Source="C:\Users\amanda\Desktop\新建 Microsoft Excel 工作表.xlsx";User ID=Admin;Password=;Extended properties=Excel 12.0')...[Sheet1$]
1 -- 如果不存在表 就是用 SELECT * INTO 表名 ... 2 -- 讀取Excel數(shù)據(jù),注意Excel必須事先關(guān)閉 3 SELECT *into Temp FROM OpenDataSource( 'Microsoft.ACE.OLEDB.12.0','Data Source="C:\Users\amanda\Desktop\新建 Microsoft Excel 工作表.xlsx";User ID=Admin;Password=;Extended properties=Excel 12.0')...[Sheet1$]
? ?--如果數(shù)據(jù)庫(kù)中有表 ?就是用 INSERT INTO 表名 ...
? ?INSERT INTO Temp1 SELECT * FROM OpenDataSource( 'Microsoft.ACE.OLEDB.12.0','Data Source="C:\Users\amandage\Desktop\新建 Microsoft Excel 工作表.xlsx";User ID=Admin;Password=;Extended properties=Excel 12.0')...[Sheet1$]
?
1 --讀取access文件 2 select * from OpenRowSet('Microsoft.ACE.OLEDB.12.0',';database=C:\Users\amanda\Desktop\奔馳-全國(guó)報(bào)價(jià)1204.mdb','select * from content') 1 --SQL寫(xiě)到Excel 2 --1.表必須存在3 --2.Excel表中需要有列名存在 4 INSERT INTO 5 OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;HDR=Yes;DATABASE=C:\Users\amanda\Desktop\新建 Microsoft Excel 工作表.xlsx', 6 'SELECT V1 FROM [Sheet1$]') 7 SELECT [周次] FROM [dbo].[Table_1] 8 9 --全部寫(xiě)入 10 INSERT INTO 11 OPENROWSET('Microsoft.Ace.OleDb.12.0','Excel 12.0;DATABASE=C:\Users\amanda\Desktop\新建 Microsoft Excel 工作表.xlsx', 12 'SELECT * FROM [Sheet1$] ') 13 SELECT * FROM [dbo].[Table_1] --使用bpc寫(xiě)出數(shù)據(jù) --1.不要有換行, 不要有odb等 --2.寫(xiě)到遠(yuǎn)程Ip下 EXEC master..xp_cmdshell 'bcp "Select * from SG..[Table_1] " queryout C:\11.xls -c -S AMANDA-PC1 -T' --”-T表示安全輸出不需要賬號(hào)密碼“ GO---寫(xiě)到本地excel --1.必須是xls格式 --2.等等 Exec master..xp_cmdshell 'bcp "Select * from SG..[Table_1]" queryout "C:\test2.xls" -c -T'--寫(xiě)出到遠(yuǎn)程以及填寫(xiě)自己的服務(wù)器和密碼賬號(hào) EXEC master..xp_cmdshell 'bcp "Select Distinct URL_SHPrice_Series from YMCUUUBI..QKDSKFDL_Spider" queryout \\10.16.**.**\SpiderURL\BasicInfo_SHPrice.txt -c -S 10.16.**.** -U 服務(wù)器登錄名 -P 密碼' --黑色的是需要自己填寫(xiě)的。 GO 1 //使用完成后,關(guān)閉Ad Hoc Distributed Queries: 2 exec sp_configure 'Ad Hoc Distributed Queries',0 3 reconfigure 4 exec sp_configure 'show advanced options',0 5 reconfigure?
轉(zhuǎn)載于:https://www.cnblogs.com/goodge/p/5137492.html
總結(jié)
以上是生活随笔為你收集整理的SQL中读取Excel 以及 bpc语言的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Java提高学习之Object(3)
- 下一篇: linux cmake编译源码,linu