Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to a file with time stamp attached

Status
Not open for further replies.

leannelau

Programmer
Mar 8, 2005
1
US
Hello,
This is the first time I'm dealing with DB2 commands. I'm very new to this and I need some help.

I have a batch file (storedatainexcel.bat) looks something like this:
====================================================
@echo off
db2 CONNECT TO MYTABLE USER mytable USING password

set tstamp = 'db2 SELECT distinct current timestamp FROM MYTABLE.TABLE1'
echo "%tstamp%"

db2 export to c:\temp\myfile%tstamp%.csv OF WSF MESSAGES c:\temp\msgs.txt select * from MYTABLE.TABLE1

db2 COMMIT WORK

db2 CONNECT RESET

db2 TERMINATE

====================================================

I need to export some data to an excel spreadsheet and name the excel file with the current system timestamp attached to it.

I ran the following at the command prompt:
C:\Program Files\SQLLIB\bin>db2cmd storedatainexcel

And the "tstamp" variable is empty (echo "").

I would like to know how to:
1) get the timestamp and store it in a local variable?
2) use this local variable in the EXPORT statement?

Thanks in advance for helping.




 
hi,
Friend I think u are looking for timestamp in the wrong place its not in mytble.table1. it should be in sysibm.sysdummy1 try this
bye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top