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, 2022 in Database by Kithuzzz
• 38,000 points
556 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, 2022 in Database by gaurav
• 23,260 points
2,979 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, 2022 in Database by gaurav
• 23,260 points
1,844 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, 2022 in Database by gaurav
• 23,260 points
5,705 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, 2022 in Database by gaurav
• 23,260 points
1,044 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, 2022 in Database by Kithuzzz
• 38,000 points
2,266 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
27,110 views
0 votes
1 answer

How to convert an excel formula to SQL to calculate daily compound interest

Here is a solution that is effective. ...READ MORE

answered Nov 26, 2022 in Others by narikkadan
• 63,600 points
872 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
791 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, 2022 in Database by Vaani
• 7,070 points
822 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, 2022 in Database by Vaani
• 7,070 points
549 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