I'm trying to insert a resultset into a linked server pointing to an Excel file.
Here is my script:
exec sp_addlinkedserver
@server = N'ExcelTEST',
@srvproduct = N'Excel 12.0',
@provider = N'Microsoft.ACE.OLEDB.12.0',
@datasrc = N'\\MyServer\MyPath\MyFile.xlsx',
@provstr = N'Excel 12.0;HDR=No,IMEX=1'
--
exec sp_addlinkedsrvlogin
@rmtsrvname = N'ExcelTEST',
@useself = N'False',
@locallogin = NULL,
@rmtuser = NULL,
@rmtpassword = NULL
GO
--
INSERT INTO ExcelTEST...[Sheet2$]
SELECT TOP 10 *
FROM dbo.myTable
GO
sp_dropserver N'ExcelTEST', 'droplogins'
GO
I then get the following error:
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ExcelTEST" returned message "Cannot update. Database or object is read-only.".
Msg 7399, Level 16, State 1, Line 6 The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ExcelTEST" reported an error. The provider indicates that the user did not have the permission to perform the operation.
Msg 7343, Level 16, State 2, Line 6 The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "ExcelTEST" could not INSERT INTO table "[ExcelTEST]...[Sheet2$]".
How can I make the connection to the Excel file read-write?