January 19, 2010 at 2:53 pm
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.
January 19, 2010 at 3:22 pm
Could you please post the DDL (CREATE TABLE statements) for the two tables? Also, how are the tables related?
January 19, 2010 at 3:33 pm
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);
January 19, 2010 at 3:57 pm
I needed an inner join statement and forgot it. problem solved. thanks for jumping in anyway. 😛
January 19, 2010 at 3:59 pm
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