Link to home
Start Free TrialLog in
Avatar of catwalk
catwalk

asked on

update help

I have a table:
tblA:
id int PK
SSN varchar(15)
FirstName varchar(30)
LastName varchar(30)

Since the id is an auto increment number, i have so-called 'duplicate' records in the table..  However, the rows are not the same.  For example i could have:
1   111-22-3333  Jason  Turner
2   111-22-3333 <no name>

I want to update all the records where the ssn are the same and the other columns do not match..

thanks in advance
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

>I want to update all the records where the ssn are the same
which of the records do you want to update, what is the rule?
which of the columns do you want to update, taking what input?
I assume you want to make the records the same, except for the ID. That begs the question, which values do you want to keep?  Also, my advice would be to get to the root of the problem and eliminate the duplicates and the need to keep them.

Avatar of catwalk
catwalk

ASKER

I want only want to keep ssn and only update columns that are null.

so in the example above:
1   111-22-3333  Jason  Turner
2   111-22-3333 <no name>

I would update firstname and lastname.  Can't update ID (as this is PK) and do not want to update ssn.

i have found cause of issue and it has been resolved - but now must clean this up
we understood that, but from which row to which row do you want to update?
And what to do if firstname is null, but lastname is not.
Avatar of catwalk

ASKER

i want to update the row with less data.   If both are null - then i will leave the column as null.

There will never be the case where there is conflicting information.  Either one row has it or it doesn't.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial