I trying to insert data from a database into multiple reports. I would like to made the destination file name to be dynamic, which was a variable. But when I replace the file name with variable, I get a syntax error.
insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=D:\Report\PeopleCounter\myDynamicFileName.xlsx;',
'SELECT * FROM [Sheet1$]')
select * from myresult;
What would be the easy way to fix this?
