1
、在SQL SERVER里查询Excel数据:
-- ======================================================
SELECT *
FROM OpenDataSource ( ' Microsoft.Jet.OLEDB.4.0 ' ,
' Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0 ' )... [ Sheet1$ ]
下面是个查询的示例,它通过用于 Jet 的 OLE DB 提供程序查询 Excel 电子表格。
SELECT *
FROM OpenDataSource ( ' Microsoft.Jet.OLEDB.4.0 ' ,
' Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0 ' )...xactions
-- -----------------------------------------------------------------------------------------------
2 、将Excel的数据导入SQL server :
-- ======================================================
SELECT * into newtable
FROM OpenDataSource ( ' Microsoft.Jet.OLEDB.4.0 ' ,
' Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0 ' )... [ Sheet1$ ]
实例:
SELECT * into newtable
FROM OpenDataSource ( ' Microsoft.Jet.OLEDB.4.0 ' ,
' Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0 ' )...xactions
-- ======================================================
SELECT *
FROM OpenDataSource ( ' Microsoft.Jet.OLEDB.4.0 ' ,
' Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0 ' )... [ Sheet1$ ]
下面是个查询的示例,它通过用于 Jet 的 OLE DB 提供程序查询 Excel 电子表格。
SELECT *
FROM OpenDataSource ( ' Microsoft.Jet.OLEDB.4.0 ' ,
' Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0 ' )...xactions
-- -----------------------------------------------------------------------------------------------
2 、将Excel的数据导入SQL server :
-- ======================================================
SELECT * into newtable
FROM OpenDataSource ( ' Microsoft.Jet.OLEDB.4.0 ' ,
' Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0 ' )... [ Sheet1$ ]
实例:
SELECT * into newtable
FROM OpenDataSource ( ' Microsoft.Jet.OLEDB.4.0 ' ,
' Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0 ' )...xactions
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16436858/viewspace-623302/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/16436858/viewspace-623302/