Export headers with results

Posted on 2011-10-20
Last Modified: 2012-06-27
In SQL Server 2005, how can I export results along with headers?  For example, I open a table with a few rows.  I'd like to export those results along with headers?  Or based off of a select.
Question by:brettr
    LVL 69

    Accepted Solution

    LVL 142

    Assisted Solution

    by:Guy Hengel [angelIII / a3]
    sqlcmd is the right tool to do this:
    the key parameters you want to use are:
    -o <output file>
    -h for the headers
    -Q for the query or -i for the input script file

    apart from those to specify connection parameters

    also, a nice tutorial starts here:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
    INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    760 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

    13 Experts available now in Live!

    Get 1:1 Help Now