从Excel文件中,导入数据到SQL数据库中,直接用下面的语句,而不是用BCP:/*===================================================================*/ --如果接受数据导入的表已经存在 insert into 表 select * from OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=YES;DATABASE=c:\test.xls',sheet1$)--如果导入数据并生成表 select * into 表 from OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=YES;DATABASE=c:\test.xls',sheet1$)/*--说明: c:\test.xls 为导入/导出的Excel文件名. sheet1$ 为Excel文件的工作表名,一般要加上$才能正常使用. --*/
我用这种方法, select * into tuantihealth from OpenDataSource ('Microsoft.Jet.OLEDB.4.0','Data Source="d:\ttjk.xls";User ID=Admin;Password=;Extended Properties="Excel 8.0;HDR=yes;";Persist Security Info=false')...alan$ --as b 报错:OLE DB provider 'Microsoft.Jet.OLEDB.4.0' does not contain table 'alan$'. The table either does not exist or the current user does not have permissions on that table.不知道怎么会这样
--如果接受数据导入的表已经存在
insert into 表 select * from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=c:\test.xls',sheet1$)--如果导入数据并生成表
select * into 表 from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=c:\test.xls',sheet1$)/*--说明:
c:\test.xls 为导入/导出的Excel文件名.
sheet1$ 为Excel文件的工作表名,一般要加上$才能正常使用.
--*/
select * into tuantihealth
from OpenDataSource
('Microsoft.Jet.OLEDB.4.0','Data Source="d:\ttjk.xls";User ID=Admin;Password=;Extended Properties="Excel 8.0;HDR=yes;";Persist Security Info=false')...alan$
--as b
报错:OLE DB provider 'Microsoft.Jet.OLEDB.4.0' does not contain table 'alan$'. The table either does not exist or the current user does not have permissions on that table.不知道怎么会这样