?
Solved

How to save stored procedure output as a usable file format eg csv, xls, xml

Posted on 2010-01-11
8
Medium Priority
?
197 Views
Last Modified: 2013-11-26
Hi,

Sometimes it would be useful to be able to copy a stored procedure's output from the output window at the bottom of the VS IDE and pasted it into Excel or Notepad or at a push an xml editor in such a way that its column layout and even column headings are retained.

Does anyone know if there is a way to do this?

Thx

Louise
0
Comment
Question by:louise001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26288669
save the results as text
0
 

Author Comment

by:louise001
ID: 26288682
Yeah I tried that but the column formatting's all over the place so it's not usable
0
 
LVL 8

Expert Comment

by:ViaTom
ID: 26289115
go into your query manager and look for a way to set the type of results.  in my case, it's under options...results tab...

set the target to grids, and the output format to tab delimited.  this will do what you want i believe.
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 8

Expert Comment

by:ViaTom
ID: 26289126
the above applies for query analyzer 8.  if you have something different post back and i can maybe find it for you.
0
 

Author Comment

by:louise001
ID: 26291273
Hi,
Thanks for your reply. I have Visual Studio 2005, 2008; SQL Server 2005, 2000.

Cheers,

Louise
0
 
LVL 8

Accepted Solution

by:
ViaTom earned 2000 total points
ID: 26295039
Louise, it looks like i misunderstood what you were asking, but i get it now.  if you could run the query in a database utility like query analyzer you can control the output format.

but if you want to specify a format for the output window in visual studio, i don't see a way.  

what i would do instead is paste the results into word, and use the replace function to replace the white space between columns with tabs, and then paste the result of that into excel so i could work with it.  a manual process, but sometimes we gotta do whatever works, huh?  :)

if your result set doesn't have any embedded spaces in any given column, this would be a single find-and-replace command.  very simple.  in the case of something like a date-time stamp, where there are embedded spaces, e.g., "12/29/2009 4:20:00 PM", you could first convert the spaces between the year and time and in front of the PM/AM into something like "++==", then do the global conversion to tabs, then reverse the change from "++==" to a space.

hth, tom
0
 

Author Comment

by:louise001
ID: 26301797
Hi ViaTom,
Yeah I realised in the end there isn't a way to avoid some kind of manual process, which is a hassle. I chose to use some code to output to Excel using the guide at http://support.microsoft.com/kb/306022 as at least that way I can re-use in the future when one of my users wants the results of some bespoke query asap.

Thanks for your help,

Louise
0
 
LVL 8

Expert Comment

by:ViaTom
ID: 26314983
welcome!
0

Featured Post

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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