PowerShell Script to export db2 tables to csvs files RRS feed

  • Question

  • Hello,

    i have the db2 commands below (EXPORT TO..) which is running on db2 command line processor.

    it export the db2 tables to csvs.

    i would like to write powershell script which will:

    1.connect the db2 database 

    2.Execute the db2 export commands 

    3.save the results on csv.

    each table on separate csv. (with time stamp - yyyy/mm/dd hh:mm:ss) 

    --table1 export command 

    EXPORT TO 'c:\backupdb2\MyDB.BUYOFFC.csv' OF DEL modified by NOCHARDEL coldelã SELECT SOSDB.BUYOFFC.*, '','','','','' FROM SOSDB.BUYOFFC;

    --table2 export command

    EXPORT TO 'c:\backupdb2\myDB.BUYRCODE.csv' OF DEL modified by NOCHARDEL coldelã SELECT SOSDB.BUYRCODE.*, '','','','','' FROM SOSDB.BUYRCODE;

    is someone can help on this ?


    Wednesday, March 21, 2018 2:21 PM

All replies

  • You would have to set up an OLEDB or native DB2 ADO.Net connection and execute your commands.

    Post in DB2 forum for assistance with this as it is vendor specific.  If you search you will also find many examples of executing SQL on DB2 databases.


    Wednesday, March 21, 2018 8:27 PM