0

I need help in export data from table to excel file using sql query. and with header and footer.

I used master..xp_cmdshell with passing db name, table name, and path where I store excel file any buddy can solve this. and any other way like query through export data to excel.

I must say I want to solve problem using query only. because I require only query.

3
  • 1
    I must say I can solve problem using query only. because I require only query. - when you can solve your problem, then why asking here? Maybe you should make your problem clearer Commented Dec 29, 2014 at 6:09
  • sorry my mistake in explain a question. Commented Dec 29, 2014 at 7:05
  • I take and apply but its not working. any other ways ? Commented Dec 29, 2014 at 7:34

1 Answer 1

0

If you need column headers the best way to export to a CSV file (which EXCEL will open) is by using sqlcmd. The syntax is something like:

c:\>sqlcmd -S servername -i c:\path\yourqueryfilename.sql -o C:\OutputPath\AFilename.csv -s","

See http://msdn.microsoft.com/en-us/library/ms162773.aspx to find the complete command line options available for SQLCMD.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.