lost header when export to csv file from sql server

Hi Expert,

When I export to csv file from sql server 2008 resoult pane, it lost header, how to solve the problem. I right click on result pane and select to 'save results as' csv file.

Thanks in advance.

LVL 1
dshi15Asked:
Who is Participating?
 
roshnipatelConnect With a Mentor Commented:
In MS SQL Server Mgmt Studio,
go to the Query Menu -> Query Options

Under Results:
Select TEXT

Check "Include Column headers in the result set"

*You may also need to update the Maximum Number of characters displayed in each column Query Options Screen
0
 
dshi15Author Commented:
this is the longest header in result pane. Q2NonTireMotorcraftTestedToughBattery
0
 
dshi15Author Commented:
and column header no space and no "_" , no special characters.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
SQLSergentMikeCommented:
SSMS options-->query results-->SQL server--> resultstogrid-->check include headers
0
 
dshi15Author Commented:
Hi roshnipatel, I had same you showed, but still not come out.
0
 
roshnipatelCommented:
Then you should go to Query -> Results To -> results to text.
Re-execute your query.

You'll be prompted to select a file location.  If you choose .rpt, once the query has ran, change the file extention to .csv

You should have the headers that way
0
 
SQLSergentMikeCommented:
Because it's results to grid like I indicated earlier, thats the default so I assume thats what your doing.
0
 
SQLSergentMikeConnect With a Mentor Commented:
Like this... like this like this
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.