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?
al4629740Asked:
Who is Participating?
 
Steve WalesConnect With a Mentor Senior 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
 
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
al4629740Author Commented:
i might need more instruction on what you mean in your answer about creating a view and exporting it
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.