Afternoon,
I have a query regarding performing an update using an inner join. Below is an example data set. What I wish to achieve is for the code column to be updated consistently across all matching records.
The desired resulting codes would be:
Can you recommend the best way to implement this. y current code is of the form:
Also, this is more of an understanding thing buy why are only 3 updates performed when there are 6 pairings using a select statement based on the same join rule.
Many Thanks,
John
I have a query regarding performing an update using an inner join. Below is an example data set. What I wish to achieve is for the code column to be updated consistently across all matching records.
Code:
ID Code CompanyGroup Contact Group
1 A 12345 84566
2 C 12345 84566
3 A 12345 84566
The desired resulting codes would be:
Code:
AC
CA
AC
Code:
update B
set code =dbo.getUniquecodeString(A.code,B.code)
from TableNAme A
inner join TableNAme _pool B on
A.CompanyGroup=B.CompanyGroup and
A.contactGroup=B.ContactGroup
where A.ID <> B.ID
Also, this is more of an understanding thing buy why are only 3 updates performed when there are 6 pairings using a select statement based on the same join rule.
Many Thanks,
John