Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6562261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:41:19+00:00 2026-05-25T13:41:19+00:00

I have a query that returns a very large data set. I cannot copy

  • 0

I have a query that returns a very large data set. I cannot copy and paste it into Excel which I usually do. I have been doing some research on how to export directly to an Excel sheet. I am running SQL SERVER 2008 on a server running Microsoft Server 2003. I am trying to use the Microsoft.Jet.OLEDB.4.0 data provider and Excel 2007. I’ve pieced together a small piece of code that looks like this from what I’ve seen in examples.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:41:20+00:00Added an answer on May 25, 2026 at 1:41 pm

    I don’t know if this is what you’re looking for, but you can export the results to Excel like this:

    In the results pane, click the top-left cell to highlight all the records, and then right-click the top-left cell and click “Save Results As”. One of the export options is CSV.

    You might give this a shot too:

    INSERT INTO OPENROWSET 
       ('Microsoft.Jet.OLEDB.4.0', 
       'Excel 8.0;Database=c:\Test.xls;','SELECT productid, price FROM dbo.product')
    

    Lastly, you can look into using SSIS (replaced DTS) for data exports. Here is a link to a tutorial:

    http://www.accelebrate.com/sql_training/ssis_2008_tutorial.htm

    == Update #1 ==

    To save the result as CSV file with column headers, one can follow the steps shown below:

    1. Go to Tools->Options
    2. Query Results->SQL Server->Results to Grid
    3. Check “Include column headers when copying or saving results”
    4. Click OK.
    5. Note that the new settings won’t affect any existing Query tabs — you’ll need to open new ones and/or restart SSMS.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a stored procedure that returns data from a SELECT query. I
I have a MySQL query that returns a result with a single column of
I have a dynamic query that returns around 590,000 records. It runs successfully the
I have a MySQL (v 5, MyISAM) query that returns different rows depending on
I have a query that is currently using a correlated subquery to return the
If I have a query to return all matching entries in a DB that
I have a query that is dynamically built after looking up a field list
I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber,
I have a query that looks like this: public IList<Post> FetchLatestOrders(int pageIndex, int recordCount)
I have a query that I'm executing from a .NET application to a SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.