SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 How to export result query to .txt or .csv
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

afonso.rodrigues
Starting Member

Brazil
1 Posts

Posted - 05/22/2014 :  14:39:44  Show Profile  Reply with Quote
Hello,
I'm Afonso Rodrigues, Developer Java, user Database.
I'm looking for a procedure to export of result query in .txt or .csv.

I'm finding bcp and sqlcmd.
But it this a single possibility?

Afonso Rodrigues

tkizer
Almighty SQL Goddess

USA
37157 Posts

Posted - 05/22/2014 :  14:58:13  Show Profile  Visit tkizer's Homepage  Reply with Quote
I'd use bcp. Here's an example:

bcp.exe "select column5, column8 from database1.dbo.table1 t1 join database1.dbo.table2 t2 on t1.column1 = t2.column1" queryout c:\temp\bcpout.csv -c -t, -T -Sserver1\instance1 -r\r\n

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000