Author |
Topic |
jonhath
Starting Member
13 Posts |
Posted - 2007-08-16 : 11:43:22
|
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
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-08-16 : 23:34:14
|
How do you export data? |
|
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2007-08-17 : 01:05:52
|
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 |
|
|
jonhath
Starting Member
13 Posts |
Posted - 2007-08-17 : 10:57:52
|
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. |
|
|
vipinM
Starting Member
9 Posts |
Posted - 2007-08-20 : 05:48:16
|
jUST CONVERT your resultset to file (Ctrl + Shift + F)and thengive the name of file with extension .CSV |
|
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2007-08-21 : 01:23:20
|
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 |
|
|
dpoirier
Starting Member
9 Posts |
Posted - 2009-10-14 : 23:09:57
|
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 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
scott_leseman
Starting Member
5 Posts |
Posted - 2009-10-15 : 07:36:05
|
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. |
|
|
dpoirier
Starting Member
9 Posts |
Posted - 2009-10-15 : 18:33:56
|
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 FREEhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926MadhivananFailing 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 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-16 : 03:10:43
|
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 FREEhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926MadhivananFailing 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 jobBut yours is not FREE. I doubt anyone would use it when FREE code is already availableMadhivananFailing to plan is Planning to fail |
|
|
dpoirier
Starting Member
9 Posts |
Posted - 2009-10-18 : 18:20:41
|
quote: Why do you bother about those things?You just use the procedure that does the jobBut yours is not FREE. I doubt anyone would use it when FREE code is already availableMadhivananFailing 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 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-19 : 01:55:49
|
quote: Originally posted by dpoirier
quote: Why do you bother about those things?You just use the procedure that does the jobBut yours is not FREE. I doubt anyone would use it when FREE code is already availableMadhivananFailing 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 MadhivananFailing to plan is Planning to fail |
|
|
|