Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

query to csv text file

Posted on 2014-04-19
6
Medium Priority
?
339 Views
Last Modified: 2014-04-19
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
Comment
Question by:al4629740
  • 3
  • 3
6 Comments
 
LVL 23

Expert Comment

by:Steve Wales
ID: 40010865
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
 

Author Comment

by:al4629740
ID: 40010868
But is it possible to export my output specifically
0
 

Author Comment

by:al4629740
ID: 40010889
i might need more instruction on what you mean in your answer about creating a view and exporting it
0
Industry Leaders: 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!

 
LVL 23

Accepted Solution

by:
Steve Wales earned 2000 total points
ID: 40010912
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
 

Author Comment

by:al4629740
ID: 40010980
What about copying it from the studio and pasting it into excel manually?
0
 
LVL 23

Expert Comment

by:Steve Wales
ID: 40011014
You could try it I suppose, not my area of expertise - always used the export wizard when I needed it done.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

916 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