SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Exporting results with header
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jonhath
Starting Member

13 Posts

Posted - 08/16/2007 :  11:43:22  Show Profile  Reply with Quote
I'm trying to export the results of a query as a CSV and I have to put the headers in manually. Is there any way to do it automatically?

Thanks

rmiao
Flowing Fount of Yak Knowledge

USA
7266 Posts

Posted - 08/16/2007 :  23:34:14  Show Profile  Reply with Quote
How do you export data?
Go to Top of Page

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 08/17/2007 :  01:05:52  Show Profile  Reply with Quote
hi jonhath,

If u trying to export in EXCEL format then check the following link.

http://weblogs.sqlteam.com/mladenp/archive/2006/07/25/10771.aspx
Go to Top of Page

jonhath
Starting Member

13 Posts

Posted - 08/17/2007 :  10:57:52  Show Profile  Reply with Quote
I need it in a CSV so the Excel link won't help.

I'm exporting by right clicking on the results and clicking "Save results as.." and save as a CSV.
Go to Top of Page

vipinM
Starting Member

India
9 Posts

Posted - 08/20/2007 :  05:48:16  Show Profile  Reply with Quote
jUST CONVERT your resultset to file (Ctrl + Shift + F)and then
give the name of file with extension .CSV
Go to Top of Page

Jeff Moden
Aged Yak Warrior

USA
649 Posts

Posted - 08/21/2007 :  01:23:20  Show Profile  Reply with Quote
Um... don't forget that row 2 will always have a bunch of dashes in it if you do it that way. Also, if a column has commas in it, it won't import the way you think it will using this method...

--Jeff Moden
Go to Top of Page

dpoirier
Starting Member

9 Posts

Posted - 10/14/2009 :  23:09:57  Show Profile  Reply with Quote
If anyone is interested, I created an SSMS 2005/2008 Addin that allows saving SQL query results as an XLS file, with header and value formats intact.

http://www.SsmsXlsExport.com/

Cheers,
David
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 10/15/2009 :  02:37:48  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by dpoirier

If anyone is interested, I created an SSMS 2005/2008 Addin that allows saving SQL query results as an XLS file, with header and value formats intact.

http://www.SsmsXlsExport.com/

Cheers,
David



But the methods suggested here would do it FREE
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

scott_leseman
Starting Member

5 Posts

Posted - 10/15/2009 :  07:36:05  Show Profile  Reply with Quote
I often write a query in analyzer and have to copy the results to Excel. The data formats don't always come out correctly and there are not column headings with the copy/paste. One method I use is to create a passthru query in Access with the query I want to run and then create an Access query that selects all fields from the passthru query (helps to first put 1 = 0 in your passthru if your passthru is long running query and change query timeout). Then I can run the access query and copy/paste the results to excel (with column headings) or export it in any format needed.
Go to Top of Page

dpoirier
Starting Member

9 Posts

Posted - 10/15/2009 :  18:33:56  Show Profile  Reply with Quote
quote:
Originally posted by madhivanan

quote:
Originally posted by dpoirier

If anyone is interested, I created an SSMS 2005/2008 Addin that allows saving SQL query results as an XLS file, with header and value formats intact.

http://www.SsmsXlsExport.com/

Cheers,
David



But the methods suggested here would do it FREE
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail



You're right it would, but you have to create an output file first with the headers, and you have to wrap your query with the insert statement.

With the addin it's just click and go, very handy if you're doing ad-hoc queries all day and saving results often. I actually wrote it for myself to make my life easier. I'm definitely not saying your way doesn't work, this is just an alternative.

David
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 10/16/2009 :  03:10:43  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by dpoirier

quote:
Originally posted by madhivanan

quote:
Originally posted by dpoirier

If anyone is interested, I created an SSMS 2005/2008 Addin that allows saving SQL query results as an XLS file, with header and value formats intact.

http://www.SsmsXlsExport.com/

Cheers,
David



But the methods suggested here would do it FREE
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail



You're right it would, but you have to create an output file first with the headers, and you have to wrap your query with the insert statement.

With the addin it's just click and go, very handy if you're doing ad-hoc queries all day and saving results often. I actually wrote it for myself to make my life easier. I'm definitely not saying your way doesn't work, this is just an alternative.

David



Why do you bother about those things?
You just use the procedure that does the job
But yours is not FREE. I doubt anyone would use it when FREE code is already available

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

dpoirier
Starting Member

9 Posts

Posted - 10/18/2009 :  18:20:41  Show Profile  Reply with Quote
quote:

Why do you bother about those things?
You just use the procedure that does the job
But yours is not FREE. I doubt anyone would use it when FREE code is already available

Madhivanan

Failing to plan is Planning to fail



It's a question of convenience I suppose. The tool is really focused on saving results ad-hoc. Given the number of times I export to Excel in a day, I don't want to keep wrapping my SQL queries and creating dummy Excel files to export to, or creating SSIS packages. And I've tried to price the tool so it pays for itself very quickly if the user is also doing lots of ad-hoc exports.

Anyhow, I'm not disputing that the methods you've outlined work and are FREE FREE FREE . I'm just offering an alternative, which I believe is EASIER and QUICKER to use - I know I would have paid for it if I'd found it!

Cheers,
David
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 10/19/2009 :  01:55:49  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by dpoirier

quote:

Why do you bother about those things?
You just use the procedure that does the job
But yours is not FREE. I doubt anyone would use it when FREE code is already available

Madhivanan

Failing to plan is Planning to fail



It's a question of convenience I suppose. The tool is really focused on saving results ad-hoc. Given the number of times I export to Excel in a day, I don't want to keep wrapping my SQL queries and creating dummy Excel files to export to, or creating SSIS packages. And I've tried to price the tool so it pays for itself very quickly if the user is also doing lots of ad-hoc exports.

Anyhow, I'm not disputing that the methods you've outlined work and are FREE FREE FREE . I'm just offering an alternative, which I believe is EASIER and QUICKER to use - I know I would have paid for it if I'd found it!

Cheers,
David



Ok. No problem

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000