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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Redirect select output

Author  Topic 

rjackman1959
Yak Posting Veteran

60 Posts

Posted - 2009-01-08 : 07:35:06
Can someone tell me if there is a way to output a select statement to a text file located on the local hard drive?

I would like to do a simple select like

select
CONVERT(CHAR(8),h.IVH_printdate,112),
h.ivh_invoicenumber,
' ',
h.ivh_ref_number,
h.ivh_totalvolume,
h.ivh_rate,
d.ivd_refnum,

but have it redirected to output.txt

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-01-08 : 07:37:55
you can use DTS or bcp for that.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-08 : 08:21:53
or even OPENROWSET
Go to Top of Page

rjackman1959
Yak Posting Veteran

60 Posts

Posted - 2009-01-08 : 08:24:08
Not sure how to use any of that. Is it within the SQL query. Can you give me an example?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-08 : 08:27:40
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/bcp-export-data-to-text-file.aspx
Go to Top of Page
   

- Advertisement -