Inserting Bulk Data from an XLSX File

  1. fr--Enable the SQL Server Advance Options  
  2. sp_configure 'show advanced options', 1  
  3. RECONFIGURE;  
  4. GO  
  5. --Enable the Ad Hoc Queries  
  6. sp_configure 'Ad Hoc Distributed Queries', 1;  
  7. RECONFIGURE;  
  8. GO  
  9. --------------------------------------------  
  10. -- The Database driver is Microsoft.ACE.OLEDB.12.0 , Excel version 12.0  
  11. -- SELECT *  
  12. -- FROM OPENROWSET   
  13. -- ('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=<<filename>>;HDR=YES',   
  14. -- 'SELECT * FROM <<sheetname>>')   
  15.   
  16. -- Example   
  17. SELECT *  
  18. FROM OPENROWSET   
  19. ('Microsoft.ACE.OLEDB.12.0''Excel 12.0;Database=C:\Employee.xlsx;HDR=YES',   
  20. 'SELECT * FROM [Sheet1$]')