If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Outputting SQL statement results to file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-09, 01:18
italia1980 italia1980 is offline
Registered User
 
Join Date: Mar 2009
Posts: 2
Outputting SQL statement results to file

Hi all,
I would like to know please how you can capture results of an SQL statement within DB2 into a flat file.

eg. select * from table >> file1

I can then look at the results of the SQL statement in "file1" as an example.

Thanks,
Adrian
Reply With Quote
  #2 (permalink)  
Old 05-21-09, 01:27
rahul_s80 rahul_s80 is offline
Registered User
 
Join Date: Jul 2006
Location: Pune , India
Posts: 433
command line :

db2 "select * from table " > file1.txt
__________________
Rahul Singh
Certified DB2 9 DBA / Application Developer
Reply With Quote
  #3 (permalink)  
Old 05-21-09, 01:29
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Use the DB2 Command Window (Windows) or normal shell, not the DB2 shell. If using Windows, see your start menu for the DB2 Command Window. If using Linux/UNIX, just use normal shell (korn/bash, etc):

db2 "select * from table" > file1
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On