Importing Data from Excel into SQL Server

A very quick way to import data from Excel into SQL Server through code is to execute the following query:

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=C:ExcelFileToImport.xlsx', [SheetWhereDataIsLocated$])

This is known as a Distributed Query where the connection is not persistent but rather only a quick ad hoc way of obtaining access to remote OLE data sources.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Related Posts