Updating Tables

  • Good morning guru's of SQL. I have a task post conversion of data from a legacy system to SQL server of correcting, or more accurately, moving the clients data to a new field in our SQL Server. Here is the deal, we converted using three tables, one of theirs (Legacy) we will call A, and the two new SQL databases, B and C. The specific data they want moved is not in Table A, I DID however find it on another legacy table, we will call Q (if you catch my drift), but I cannot seem a way to connect Q to A, B or C easily. I thought I had it but found it was not always a steady static field or I was creating a loop which is no good.

    Is there an easy way to find common data fields between two tables? I tried to write a script, but unfortunately it is over my head. Or is there something I am overlooking. I have tried UPDATE, CASE, etc. But it comes back to tying the tables together, I think.

  • You'll have to provide more details on what these tables look like, including the DDL And PK/FK definitions.

    You connect tables, not databases, so I'm not sure how you are describing A, B, and C as relating. If these are databases, then this doesn't help.

    If you do not have any PKs that you can use to join the information, there's no way to update things. The trick is to look at how you would do this manually. If the tables were separate pieces of paper, how do you decide what to copy from what paper to which place on another? Once you know that logic, we can usually help write a script.

  • Steve, apologies about my terminology - still learning and realizing it makes a huge difference. I think you hit the crux. i just don't think there is any way to connect these two tables either directly or indirectly; I have just been digging so hard due to the fact that i wanted this to work so darn much. Anyway, thanks for the thoughts.

  • mhildebrand (11/10/2014)


    Steve, apologies about my terminology - still learning and realizing it makes a huge difference. I think you hit the crux. i just don't think there is any way to connect these two tables either directly or indirectly; I have just been digging so hard due to the fact that i wanted this to work so darn much. Anyway, thanks for the thoughts.

    I know you said that you couldn't find indirect methods but have you looked for the indirect method known as a "Bridging Table"? That's a table with nothing but the PK values of two tables so that Many-to-Many relationships could be made

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff, I actually tried that without knowing the term, but there is nothing in common data wise between these tables, which is lousy. I think I just have to let my client know this is undeliverable.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply