Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is there a way to read a excel file

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2007-04-23 : 13:46:37
into the sql query analyzer?
Thanks.

Jeff

MutantNinjaLoungeSinger
Starting Member

14 Posts

Posted - 2007-04-23 : 14:13:55
If by that you mean to ask if there is a way to import Excel into SQL, yes.

http://support.microsoft.com/kb/321686


If you want to query an excel document using sql query analyzer, I'm sure there's some hacky way of doing it through a linked excel table.
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-04-23 : 15:06:54
Opendatasource works in both cases.
Go to Top of Page

sshelper
Posting Yak Master

216 Posts

Posted - 2007-04-23 : 15:13:03
Check out the following links on how to read and import Excel files using Query Analyzer:

http://www.sql-server-helper.com/tips/read-import-excel-file-p01.aspx
http://www.sql-server-helper.com/tips/read-import-excel-file-p02.aspx
http://www.sql-server-helper.com/tips/read-import-excel-file-p03.aspx

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page

jeff06
Posting Yak Master

166 Posts

Posted - 2007-04-23 : 16:27:13
Thanks
basically, I want import an excel file into sql query analyzer as temprary table for further use. what is the simpliest way to do that?
Thanks
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-04-23 : 16:45:21
Use Opendatasource, you can find sample code in above links.
Go to Top of Page

moonmonkey
Starting Member

4 Posts

Posted - 2011-02-10 : 05:40:02
Does Excel need to be installed on the SQL Server, in order for the OPENROWSET command to work? I have tried the following statement on a number of servers:

SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\temp\TTFAU.xls',
'SELECT * FROM [Template$]')

..and the command only seems to work on my desktop PC, where Excel is installed.
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2011-02-10 : 07:15:32
There may be a "path issue" in that SQL server can't see the C:\ drive as it's local to your PC.
Take Excel out of the equation 1st.

Try to load a text file and see what error (or not) sql has with the path of the file you are trying to process. Remember the path is relative to the SQL Engine, and not relative to the client PC you are executing it from.

Then once you have got that working, move onwards to invoking Excel.
Go to Top of Page
   

- Advertisement -