Solved

query to csv text file

Posted on 2014-04-19
6
321 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
Comment Utility
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
Comment Utility
But is it possible to export my output specifically
0
 

Author Comment

by:al4629740
Comment Utility
i might need more instruction on what you mean in your answer about creating a view and exporting it
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
Comment Utility
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
Comment Utility
What about copying it from the studio and pasting it into excel manually?
0
 
LVL 22

Expert Comment

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now