SELECT * FROM OpenDataSource( \\\\\\\'Microsoft.Jet.OLEDB.4.0\\\\\\\',\\\\\\\'Data Source="c:\\\\\\\\DB.mdb";User ID=Admin;Password=\\\\\\\')……表名
2.将access导入SQL server在SQL SERVER 里运行:
SELECT * INTO newtable FROM OPENDATASOURCE (\\\\\\\'Microsoft.Jet.OLEDB.4.0\\\\\\\',\\\\\\\'Data Source="c:\\\\\\\\DB.mdb";User ID=Admin;Password=\\\\\\\' )……表名
3.将SQL SERVER表里的数据插入到Access表中在SQL SERVER 里运行:
insert into OpenDataSource( \\\\\\\'Microsoft.Jet.OLEDB.4.0\\\\\\\',\\\\\\\'Data Source=" c:\\\\\\\\DB.mdb";User ID=Admin;Password=\\\\\\\')……表名 (列名1,列名2) select 列名1,列名2 from sql表
实例:insert into OPENROWSET(\\\\\\\'Microsoft.Jet.OLEDB.4.0\\\\\\\',\\\\\\\'C:\\\\\\\\ db.mdb\\\\\\\';\\\\\\\'admin\\\\\\\';\\\\\\\'\\\\\\\', Test) select id,name from Test
INSERT INTO OPENROWSET(\\\\\\\'Microsoft.Jet.OLEDB.4.0\\\\\\\', \\\\\\\'c:\\\\\\\\trade.mdb\\\\\\\'; \\\\\\\'admin\\\\\\\'; \\\\\\\'\\\\\\\', 表名) SELECT * FROM sqltablename
二、SQL SERVER 和EXCEL的数据导入导出
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