Export Command SQL with carriage return

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • no_spam_for_gman

    #1

    Export Command SQL with carriage return


    Hi,

    I have been using the db2 export function for quite sometimes.
    Everytime I want to use it I have to remove every carriage return from
    my SQL statement and have it all on one line as shown in the following
    simplistic example:

    db2 export to myfile.txt of del select a,b,c from staff

    This can be time consuming when you have big SQL joining many tables
    that contains several where clauses.

    Is it possible to somehow pass a SQL with carriage returns? Have the
    SQL store in a text file for example like so

    SELECT A,
    B,
    C
    FROM STAFF


    Let me know.....
    THANKS

  • no_spam_for_gman

    #2
    Re: Export Command SQL with carriage return

    Hi,

    Does anybody know how to do it? I was able to get close to what I want
    but the data is not exported in a comma delimited file, it simply
    outputs evrything:

    Example:
    extract.sql contains my SQL with carriage return and ; is the
    termination character.
    output.txt is the report it generates.
    -x indicates to Suppress printing of column headings

    C:\Program Files\IBM\SQLLI B\BIN>db2 -x -td; -f "extract.sq l" -r
    "output.txt "

    Please help....

    Comment

    • sethwai@yahoo.com

      #3
      Re: Export Command SQL with carriage return

      Continue to use the export command. put all the export statements in a
      single file. You can use new lines to your heart's content. End the
      last line with a ";". then execute db2 -tvf "export_stm ts". This
      should work.

      Lew

      no_spam_for_gma n wrote:
      Hi,
      >
      Does anybody know how to do it? I was able to get close to what I want
      but the data is not exported in a comma delimited file, it simply
      outputs evrything:
      >
      Example:
      extract.sql contains my SQL with carriage return and ; is the
      termination character.
      output.txt is the report it generates.
      -x indicates to Suppress printing of column headings
      >
      C:\Program Files\IBM\SQLLI B\BIN>db2 -x -td; -f "extract.sq l" -r
      "output.txt "
      >
      Please help....

      Comment

      • no_spam_for_gman

        #4
        Re: Export Command SQL with carriage return

        Thank you so much, that worked!

        Comment

        • VGD

          #5
          Re: Export Command SQL with carriage return

          Try this

          SELECT A, ^
          B, ^
          C ^
          FROM STAFF

          It works on Windows Command Line

          Regards.

          Vicente



          "no_spam_for_gm an" <gaetan@gmail.c omescribió en el mensaje
          news:1160528733 .417416.156500@ m7g2000cwm.goog legroups.com...
          >
          Hi,
          >
          I have been using the db2 export function for quite sometimes.
          Everytime I want to use it I have to remove every carriage return from
          my SQL statement and have it all on one line as shown in the following
          simplistic example:
          >
          db2 export to myfile.txt of del select a,b,c from staff
          >
          This can be time consuming when you have big SQL joining many tables
          that contains several where clauses.
          >
          Is it possible to somehow pass a SQL with carriage returns? Have the
          SQL store in a text file for example like so
          >
          SELECT A,
          B,
          C
          FROM STAFF
          >
          >
          Let me know.....
          THANKS
          >


          Comment

          • Tonkuma

            #6
            Re: Export Command SQL with carriage return

            Please use Command Editor. Not CLP.

            Comment

            • no_spam_for_gman

              #7
              Re: Export Command SQL with carriage return

              I find execute db2 -tvf "export_stm ts" is the best way. I can store my
              SQL in files.

              Comment

              Working...