I'd like to create a loop and an IF Else statement in SQL Server to check a set of condition in each row of a table and do something if all conditions are met.
I'd like to do something like the example below in SQL Server:
For each row in table1:
If (table1.dob is null
and table1.name = table2.name
and table1.surname=table2.surname){
update table1
set dob = table2.dob}
Else {
Do nothing
End If
End loop
Can anyone help me please?
Thanks,
Eduardo