Export SQL query data to Excel

0 votes

My query returns a huge amount of data. I normally copy and paste it into Excel, but I cannot. I have been looking for the best ways to export straight to an Excel sheet. On a machine running Microsoft Server 2003, I have SQL SERVER 2008 installed. I'm attempting to use Excel 2007 with Microsoft.Jet.OLEDB.4.0 data provider. From samples I've seen, I've pulled together a short piece of code that appears like this.

INSERT INTO OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source=C:\Working\Book1.xlsx;Extended Properties=EXCEL 12.0;HDR=YES')
SELECT productid, price FROM dbo.product

However this is not working, I am getting an error message saying:

"Incorrect syntax near the keyword 'SELECT'".

Does anyone have any ideas about how to do this or possibly a better approach?

Aug 18 in Database by Kithuzzz
• 12,240 points
16 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

How to Export Tally Data programmatically to CSV or Excel format

Open data (Ledger/P&L or Balance Sheet) that ...READ MORE

answered Mar 15 in Database by gaurav
• 18,960 points
371 views
0 votes
1 answer

Easy way to export multiple data.frame to multiple Excel worksheets

To export numerous data frames from R ...READ MORE

answered Mar 25 in Database by gaurav
• 18,960 points
366 views
0 votes
1 answer

How to Export Tally Data programmatically to CSV or Excel format

Tally Data in Excel or PDF: How ...READ MORE

answered Mar 30 in Database by gaurav
• 18,960 points
157 views
0 votes
1 answer

How to run a SQL query on an Excel table?

On Excel tables, how to construct and ...READ MORE

answered Apr 11 in Database by gaurav
• 18,960 points
167 views
0 votes
0 answers

SQL query to select data between two dates and times

My table contains a [time] field that ...READ MORE

Aug 25 in Database by Kithuzzz
• 12,240 points
10 views
0 votes
2 answers

Write a SQL query to find the names of employees that begin with ‘S’

Select ename From emp Where ename like"s%"; READ MORE

answered Oct 7, 2021 in Database by anonymous
14,703 views
0 votes
1 answer

Calculate Time Intersection to Correlate Sequences of Independent Events

I think this solution requires a CROSS JOIN implementation. ...READ MORE

answered Oct 26, 2018 in Power BI by Upasana
• 8,620 points
330 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 7,020 points
121 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4 in Database by Vaani
• 7,020 points
45 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4 in Database by Neha
• 8,920 points
216 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP