I am using below code to export data from SQL Server to Excel:
update openrowset('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=E:\..\.xlsx;',
'select Column1,Column2,Column3 FROM [Sheet1$]')
set Column1=null,Column2=null,Column3=null
insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=E:\..\.xlsx;', 'SELECT * FROM [Sheet1$]')
select Column1,Column2,Column3 from table_Name
I am using 64-bit OS with 64-bit Excel 2010.
This code is working fine on 32-bit system with 32-bit Excel but in 64-bit system first time it's working fine as expected but next time onwards I want to set blank all the record and insert new records and update is working but after the update when I am executing the insert command SQL Server is showing how many rows are affected but when I open the file it's totally blank.