SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
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  

Starting Member

1 Posts

Posted - 05/22/2014 :  14:39:44  Show Profile  Reply with Quote
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

Almighty SQL Goddess

38114 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
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.03 seconds. Powered By: Snitz Forums 2000