日期:2014-05-17 浏览次数:20436 次
--------2000的供参考---------- if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[测量项目]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table 测量项目 go select * into 测量项目 from OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 8.0;IMEX=1;HDR=YES;DATABASE=C:\初始化信息.xls' --c:\test.xls是excel文件名 ,测量项目$) --sheet1$是工作表名+$
------解决方案--------------------
Execl(2003)数据 导入 SQL Server(2005) .
------解决方案--------------------
------2005的,供参看 --第1步 exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure --第2步 insert into DBtableName(ColumnName 1,ColumnName 2) select ColumnName 1, ColumnName 2 from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source=D:\Excel1.xls; User ID=;Password=; Extended properties=Excel 8.0')...[sheet1$]
------解决方案--------------------
DataTable Excel_UserInfo = new DataTable(); string strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + fileInfo.FullName + ";" + "Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1;\""; string strExcel = "select * from [sheet1$]"; using (OleDbDataAdapter adaptor = new OleDbDataAdapter(strExcel, strConn)) { DataSet ds = new DataSet(); adaptor.Fill(ds); Excel_UserInfo = ds.Tables[0]; }