0

I have a some data in an excel sheet in the form of a table. I want to run an sql query on that data. I am okay to use the data raw from the csv.

Is it possible to create a temporary view or table using that data within the query itself. I don't want to create a separate table for this excel data.

2
  • what are you taking action for this csv Commented Feb 21, 2017 at 11:24
  • I assumed you are using SQL Server, however please provide which RDBMS you are using Commented Feb 21, 2017 at 11:30

2 Answers 2

3

For SQL Server 2008 and above you can use OPENROWSET

In simplest form it will look like this:

SELECT * FROM OPENROWSET(BULK 'data.csv', SINGLE_CLOB) AS DATA;

Just remember to specify full file path.

Sign up to request clarification or add additional context in comments.

Comments

2

There are a bunch of answers for this already... Have you searched?

You want to do something like this;

Select * 
into [temp_table$]
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\spreadsheet.xls;HDR=YES;IMEX=1',
'SELECT * FROM [SHEET1$]')

Like in this question: Get Excel sheet into temp table using a script

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.