我運行下面的命令選擇多張文件從文件夾,日期到SQL Server
DECLARE @sql varchar(MAX);
DECLARE @path varchar(255);
SET @path = 'E:\BILL PRINT\RAVI\'
SET @sql = 'SELECT * FROM OPENROWSET(''Microsoft.ACE.OLEDB.12.0'',
''Excel 12.0; Database='[email protected]+''+'*.xlsx;'+' HDR=YES; IMEX=1'',
''SELECT * FROM [sheet1$]'')';
SELECT @sql
EXEC (@sql)
但我得到這個錯誤:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "The Microsoft Access database engine could not find the object 'E:\BILL PRINT\RAVI*.xlsx'. Make sure the object exists and that you spell its name and the path name correctly. If 'E:\BILL PRINT\RAVI*.xlsx' is not a local object, check your network connection or contact the server administrator.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
是不是可以從指定的Excel文件導入數據?
請幫我
是的,這是可能的,我想你應該從路徑中刪除* char。 –
沒問題仍然存在 – user8205502