Click here to Skip to main content
15,885,985 members
Articles / Database Development / SQL Server
Tip/Trick

Reading Excel file in SQL Server

Rate me:
Please Sign up or sign in to vote.
4.31/5 (8 votes)
17 Jan 2011CPOL 64K   10   6
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)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralJust what we were looking for today Pin
Member 1068382119-Mar-14 11:27
Member 1068382119-Mar-14 11:27 
QuestionI get an error regarding JET OLEDB Pin
sharp_k19-Apr-12 10:46
sharp_k19-Apr-12 10:46 
Generalnice 1!!! thanx Pin
sun_ak4725-Dec-11 22:01
sun_ak4725-Dec-11 22:01 
GeneralReason for my vote of 5 nice Pin
cgy22015-Aug-11 22:27
cgy22015-Aug-11 22:27 
GeneralReason for my vote of 4 thanks for sharing Pin
Pranay Rana17-Jan-11 23:07
professionalPranay Rana17-Jan-11 23:07 
GeneralEdited all-caps, added description Pin
Indivara17-Jan-11 21:22
professionalIndivara17-Jan-11 21:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.