Good day..
I am trying to create a linked server on sql to export data from a stored procedure to excel. This is my code below.
EXEC sp_addlinkedserver @server = 'TEST_EXCEL9',
@srvproduct = 'Excel',
@provider = 'Microsoft.ACE.OLEDB.12.0',
@datasrc = +@FilePath,
@provstr = 'Excel 12.0;IMEX=1;HDR=YES;';
The source problem is that anytime i try to use my stored procedure which is below to export data to excel
``SET @sSQLbranch = 'INSERT INTO OPENROWSET(''Microsoft.ACE.OLEDB.12.0'',
''Excel 12.0;HDR=YES;Database=' +@FilePath+ '\FINANCIAL_INCLUSION_REPORT-30062022.xlsm;'',
''SELECT * FROM [Data$]''
)
SELECT * FROM ##Accountbybranch'
EXEC(@sSQLbranch);
I get this error message
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
So my challenge is that the linked server created has the appropriate data source that is required for the stored procedure to work but i need the data source to be configured with a filepath variable so i can change it at will
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.