| Bret Halford 2005-04-09, 8:26 pm |
|
VMI wrote:
> How can I write a recordset to an ascii file? I have to add
> this functionality to a stored procedure.
>
> Thanks.
Where do you want the file - on the client machine, or the server host
machine?
This kind of thing would usually be approached on the client end. Some
clients have built-in ways to turn file logging on and off. For
instance,
SQSH http://www.isug.com/Sybase_FAQ/ASE/section9.html#9.6.1
uses shell-like redirection or pipes
1> select * from sysobjects
2> go 2>/dev/null >/tmp/objects.txt
The ISQL client doesn't have anything interactive - you can send all the
output
for the whole session to a file using the -o parameter when you invoke
it, but that
is about it.
From the server side, you can put information in files by using
xp_cmdshell
to CAT lines onto a file. You could also purchase the optional external
file systems
(XFS) license which will let you create proxy tables on file systems -
then you could
just insert your records into a proxy table mapped to a file.
-bret
|