Solved

query to csv text file

Posted on 2014-04-19
6
333 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
[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
  • 3
  • 3
6 Comments
 
LVL 22

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 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 22

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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
Viewers will learn how the fundamental information of how to create a table.

636 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