Results 1 to 3 of 3

Thread: Complex Update

  1. #1
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Unanswered: Complex Update

    I have some code that runs in SQL Server that I need to translate into DB2

    Code:
    update dbo.stg_joc_tbl 
    set office = s.office
    from dbo.stg_joc_tbl j, dbo.REF_NA_SALES_XREF_TBL s
    where j.district = s.district_code
    I have done this once but I have lost the script. And I have also forgoten what I did. I know I did a nested select statment something like

    Code:
    update dbo.stg_joc_tbl 
    set office = s.office
    from dbo.stg_joc_tbl j
    where j.district in (select distinct district_code from REF_NA_SALES_XREF_TBL)
    If anyone can look at this and help me remember it would be greatly apreciated.
    Jim
    ------------
    And back to SQL Server....I always find my way home
    View my Linkedin profile

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    You're almost there

    Code:
    update dbo.stg_joc_tbl  j
    set j.office = (select s.office from dbo.REF_NA_SALES_XREF_TBL s
    where j.district = s.district_code)

  3. #3
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Quote Originally Posted by n_i
    You're almost there

    Code:
    update dbo.stg_joc_tbl  j
    set j.office = (select s.office from dbo.REF_NA_SALES_XREF_TBL s
    where j.district = s.district_code)

    Yup That was it!!!! Thanx for the help.
    Jim
    ------------
    And back to SQL Server....I always find my way home
    View my Linkedin profile

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •