Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 Transact-SQL (2012)
 SQL query export to a file
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sportsguy
Starting Member

USA
39 Posts

Posted - 03/28/2013 :  10:36:24  Show Profile  Reply with Quote
How do i set the output file structure and destination in code?

Pipe delimited
e:\DATA\Extracts\filename.txt

I hate having to go in manually and set it up everytime,
as this is not the default. .

thanks in advance. . .

MS Access 20 years, SQL hack

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 03/28/2013 :  10:47:39  Show Profile  Reply with Quote
use bcp with queryout option.

http://www.nigelrivett.net/SQLTsql/BCP_quoted_CSV_Format_file.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sportsguy
Starting Member

USA
39 Posts

Posted - 03/28/2013 :  11:51:21  Show Profile  Reply with Quote
visakh16,

sorry, you link describes importing text to a data table,
I am asking about exporting a query to text. . .

thanks for trying though. ..

sportsguy

MS Access 20 years, SQL hack
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 03/28/2013 :  12:18:31  Show Profile  Reply with Quote
bcp has a query out option which you can utilise to export query results to text. that link was just to show usage of format file

see

http://sqlfool.com/2008/12/bcp-basics/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next 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.08 seconds. Powered By: Snitz Forums 2000