4 export-to-excel sql-server-2008
我想从Excel导出MSSQL SERVER 2008中的数据,但我有错误
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"
returned message "Bookmark is invalid.".
Msg 7343, Level 16, State 2, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)"
could not INSERT INTO table "[Microsoft.ACE.OLEDB.12.0]".
Run Code Online (Sandbox Code Playgroud)
它是我的excel文件导出(文件保存格式97-2003)

我的疑问

告诉我,为什么我会收到错误?我需要做什么?
经过多次与这个问题的斗争,我找到了以下解决方案:
打开SQL Server并运行以下命令:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
GO
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
GO
Run Code Online (Sandbox Code Playgroud)
现在,如果您正在运行OPENROWSET调用,则需要放弃使用旧JET参数进行的调用并使用新调用,如下所示:
(*Example, importing an EXCEL file directly into SQL):
DONT DO THIS….
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;HDR=YES;Database=c:\PATH_TO_YOUR_EXCEL_FILE.xls','select * from [sheet1$]')
USE THIS INSTEAD…
SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=c:\PATH_TO_YOUR_EXCEL_FILE.xls','select * from [sheet1$]')
*At this point resolved two SQL issues and ran perfectly
Run Code Online (Sandbox Code Playgroud)试试这个
INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 8.0;Database=C:\Export.xls;',
'SELECT id_sale FROM [ExportSheet$]')
SELECT id_sale
FROM dbo.Sale
Run Code Online (Sandbox Code Playgroud)
要么
INSERT INTO OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\Export.xls;Extended Properties=EXCEL 8.0')...[ExportSheet$]
SELECT id_sale
FROM dbo.Sale
Run Code Online (Sandbox Code Playgroud)