Update Statement Creates Unwanted Nulls

  • Let's say xTest has 9 records and no nulls. xUpdate has 6 records. I am updating locations for 6 people. After I execute this statement, the remaining 3 records in xTest end up with nulls in location:

    update xTest

    set location = (select [location] from xUpdate

    where xTest.name = xUpdate.name)

    Why am I getting nulls? I don't get nulls if my xUpdate file is the full dataset with the correct values.

  • Could you please post the DDL (CREATE TABLE statements) for the two tables? Also, how are the tables related?

  • Also, give this code a try in a test environment.

    update dbo.xTest set

    location = xu.location

    from

    dbo.xTest xt

    inner join dbo.xUpdate xu

    on (xt.name = xu.name);

  • I needed an inner join statement and forgot it. problem solved. thanks for jumping in anyway. 😛

  • Lynn, you were right-on with the inner join. thanks.

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

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