September 12, 2005 at 11:57 am
I'm trying to figure out a way to send the results of a query to a txt file. Is this possible? If so, what is the syntax?
Thanks in advance.
Justin
September 12, 2005 at 12:00 pm
Why would you want to do that?
September 12, 2005 at 12:03 pm
You can use the bcp utility from command line.
bcp "SELECT fname, lname, address, city, state, zip FROM mydb..users order by state, city" queryout Users.txt -c -Smysqlserver -Umyusername -Pmypassword
Books online has lot of info on this.
September 12, 2005 at 12:08 pm
Because I need to schedule several queries to run overnight and I have to save the results and I'd rather not have to do it all manually.
September 12, 2005 at 12:10 pm
Why not save the results of the query in a reporting table... or send an e-mail with the results of the query??
September 12, 2005 at 12:15 pm
For auditing purposes, I need it as a file, not as just an email. Can I use xp_sendmail to send results as an attachment instead of just putting it in the message body?
September 12, 2005 at 12:20 pm
Ah. Ok, I got it working. Thanks, guys
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply