How to export sql server table data to excel sheet.
insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=D:\Book1.xlsx;',
'SELECT * FROM [SheetName$]') select TOP 5 CustomerID from Customers
I used the above query but it shows following error
Msg 7308, Level 16, State 1, Line 1 OLE DB provider 'Microsoft.ACE.OLEDB.12.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.