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: 340
  • Last Modified:

query to csv text file

If I pull up a query in SQL, how can I take the output and create a csw text file in the management studio?
0
al4629740
Asked:
al4629740
  • 3
  • 3
1 Solution
 
Steve WalesSenior Database AdministratorCommented:
You should be able to go, from Object Explorer, expand to the table you want and do Tasks -> Export Data.

From there you can select CSV, Excel or what not.

If you want specific data from more than one table, you may want to create a view and do it that way.

Failing that, there's not much more than this kind of thing:

select col1+','+col2+','+coll3
from table where condition=value
0
 
al4629740Author Commented:
But is it possible to export my output specifically
0
 
al4629740Author Commented:
i might need more instruction on what you mean in your answer about creating a view and exporting it
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
Steve WalesSenior Database AdministratorCommented:
Actually, I led you astray, you don't need to define a view.

Right click on the database name in SSMS, select Tasks and Export Data.

It will launch a wizard.

Select SQL as the input, Excel and output.

Then you have the option to export a table or view or write a query.

Choose write a query - put in your query and complete your export.

Then you can export that to CSV.

There's no easy way to do it otherwise that I'm aware of.
0
 
al4629740Author Commented:
What about copying it from the studio and pasting it into excel manually?
0
 
Steve WalesSenior Database AdministratorCommented:
You could try it I suppose, not my area of expertise - always used the export wizard when I needed it done.
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

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