Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / SQL-Server

Reading Excel file in SQL Server

4.31/5 (8 votes)
17 Jan 2011CPOL 64.9K  
Shows how to read an Excel file using SQL query commands from SQL Server
Syntax:
SQL
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
          'Excel 8.0;Database=<FILE_PATH>',
          'SELECT * FROM [Sheet1$]')



Example:
SQL
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
          'Excel 8.0;Database=\\labdbs1\APPLICATIONS\branch.xls',
          'SELECT * FROM [Sheet1$]')

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)