Export resultset to file


Export resultset to file

Hi all,

I want to write a procedure which will export the resultset to a text file.
for example
SELECT * FROM table1

The resultset of the above query needs to be written to text file at c:\myfolder\mytextfile.txt .

how can i achieve this, pls provide a sample procedure which is syntactically correct.

Thanks in advance .

Re: Export resultset to file

A stored procedure runs on the Teradata server. It cannot write directly to a client file.

A stored procedure can declare a cursor to be returned as a result set to the client, and a client such as BTEQ can easily export the result set to a local file. For more information read the topic "Returning Result Sets From a Stored Procedure" in the SQL manual volume entitled "Stored Procedures and Embedded SQL".