Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

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

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
louise001
Asked:
louise001
  • 4
  • 3
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
save the results as text
0
 
louise001Author Commented:
Yeah I tried that but the column formatting's all over the place so it's not usable
0
 
ViaTomCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ViaTomCommented:
the above applies for query analyzer 8.  if you have something different post back and i can maybe find it for you.
0
 
louise001Author Commented:
Hi,
Thanks for your reply. I have Visual Studio 2005, 2008; SQL Server 2005, 2000.

Cheers,

Louise
0
 
ViaTomCommented:
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
 
louise001Author Commented:
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
 
ViaTomCommented:
welcome!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now