Import specific colums

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wrangler2004
    New Member
    • Apr 2007
    • 12

    Import specific colums

    Hi,

    I have a DB table called 'OPERATOR' that has several columns. Two of those columns are called OPERATOR_ID and WINDOWS_USERID.

    I am trying to take an external csv file that contains only these two fields and import them into the table setting the windows_userid in my table equal to the windows_userid in my csv.

    I've also created a temporary table with the csv data, which contains the two columns, but can't seem to figure out how to take the two columns from that table and import it into the other.
  • wrangler2004
    New Member
    • Apr 2007
    • 12

    #2
    Originally posted by wrangler2004
    Hi,

    I have a DB table called 'OPERATOR' that has several columns. Two of those columns are called OPERATOR_ID and WINDOWS_USERID.

    I am trying to take an external csv file that contains only these two fields and import them into the table setting the windows_userid in my table equal to the windows_userid in my csv.

    I've also created a temporary table with the csv data, which contains the two columns, but can't seem to figure out how to take the two columns from that table and import it into the other.
    I'm sure I need to use an 'update' statement on the target table, but can't seem to figure out how.

    The following select statement does pull in the information i need...if I can only merge the data:

    SELECT TABLE1.OPERATOR _ID, TTABLE1.WINDOWS _USERID, USERLIST1.ID, USERLIST1.EMP_I D
    FROM MYSCHEMA.TABLE1 AS OPERATOR, MYSCHEMA.USERLI ST1 AS USERLIST1
    WHERE TABLE1.OPERATOR _ID = USERLIST1.ID

    Comment

    • wrangler2004
      New Member
      • Apr 2007
      • 12

      #3
      OK, I figured it out.

      I guess I could have used DB2 merge, but I opted for the simpler approach with an update statement:

      DB2 UPDATE TARGETTABLE.OPE RATOR A SET WINDOWS_USERID=
      (SELECT EMP_ID FROM SOURCETABLE B WHERE A.OPERATOR_ID=B .ID)

      Comment

      Working...