Solved

query to csv text file

Posted on 2014-04-19
6
330 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 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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 ?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

821 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