Copy resultset to excel with headers included

Posted on 2007-07-19
Last Modified: 2012-05-05

On Enterprise Manager, I used to highlight the columns on a result grid, then copy and paste it to excel (and the headers will be included).  We have upgraded to SQL 2005, and I cannot do it anymore  in SQL Server Management Studio.

Is there a way to copy an paste the result set of queries of views to excel, an include the headers with it?

Question by:crickpaolo
    LVL 29

    Expert Comment

    Not sure but you can run the query from within Excel which will give the headers.
    Data - import data - new database query
    Select a dsn and then type/paste your query there.
    ok - return data to excel
    LVL 9

    Accepted Solution

    Go to Tools->Options ->Query Results ->SQL server -> Result to Grid and select the option "Include column header when copying or saving"

    Author Comment

    Thanks qgompe. I tried it but it does not work work for some reason. Is there a special way of cutting and pasting to excel?

    Here's what I did:
    1. Selected the option to "Include column header when copying and pasting"
    2. Restarted SQL Management Studio
    3. Clicked on the upper left corner of my result grid, to select the entire result grid
    4. Right Clicked, the selected copy
    5. Pasted on Excel

    But it still only pastes the contents without the header. help?

    LVL 9

    Expert Comment

    Try selecting the same option but for "Result to Text" too

    Author Comment

    Thanks qgompe.  The inlude headers option was already selected on the Result to text option.  It looks like I cannot include the headers whenever I export the result set from an Open Table or Open View.  It did work however when I exported the resultset from a Query.

    I guess Microsoft just reversed this functionality in SQL Server 2005. In Enterprise Manager, you can export the headers when opening a table/view, but not when exporting recordsets from within  Query Analyzer.  Right now, it's the other way around...


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now