我使用這個代碼導入Excel文件到SQL表Excel以SQL表的錯誤消息7350
USE master
GO
sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO
insert into memberform (id)
SELECT * FROM OPENROWSET ('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\\test.xls;HDR=YES', 'select * from [Sheet1$]')
但我發現了錯誤:
Msg 7350, Level 16, State 2, Line 1 Cannot get the column information from OLE DB provider "Microsoft.Jet.OLEDB.4.0" >for linked server "(null)".
有什麼我應首先在sql中進行參數化?
Docs:「OPENROWSET不接受變量的參數。」您需要按照消息中的步驟操作。 – Serg
請不要在'OPENROWSET'命令中使用任何空格! –