Write to a text file from Stored Procedure
I need to write the results of a select statement
to a text file. I am thinking I can call an object
from the procedure and write the file. Before I go
through all of this trouble does anyone have any better
ideas? Is it possible just to do this from the select
statement?
Thanks,
Mike
Blessed is the man who fears the LORD, who delights greatly in his commandments. Psalms 112:1
Peter J. Boettcher posted this at 22:03 — 25th April 2002.
They have: 812 posts
Joined: Feb 2000
If you have access to Extended Stored Procs (xp) you can use xp_cmdshell to gain access to the command line and do whatever you want, or just send control back to the web server and create the file there.
PJ | Are we there yet?
pjboettcher.com
mairving posted this at 01:13 — 26th April 2002.
They have: 2,256 posts
Joined: Feb 2001
It might help knowing what DB and Server you are running. Peter gives you the how to in Windows. On a 'nix box using MySQL at the shell, the command would be:
<?php
SELECT * from table
WHERE fieldname='value'
INTO outfile \"/home/username/filename.txt\";
?>
Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states
mycoolross posted this at 12:16 — 26th April 2002.
They have: 82 posts
Joined: Oct 2001
Sorry guys
I am using SQL Server 2000
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.