I have two tables:
T1:
CODE FULL_NAME
and T2:
CODE FIRST_NAME LAST_NAME
all of the columns are of type NVARCHAR.
Some CODE cells in T1 are empty and I need to get them from T2. I need to use FULL_NAME information in T1 and search in LAST_NAME and FIRST_NAME columns in T2. How to write such an UPDATE?
What I wrote so far is:
UPDATE IMPORT_DATA.RDBS_DATA_STORAGE
SET child_iin = pd.iin
FROM IMPORT_DATA.RDBS_DATA_STORAGE
INNER JOIN nedb.PERSONAL_DATA pd ON child_iin LIKE 'N' + '%' + pd.LAST_NAME + '%' + ' ' + 'N' + '%' +
pd.FIRST_NAME + '%'
WHERE LEN(child_iin) < 1;
But unsuccessful.
EDIT:
I can't just use WHERE t1.FULL_NAME=t2.FIRST_NAME + ' ' + t2.LAST_NAME, because i can have such scenario where t1.FULL_NAME = 'Jorsh Arthur Weasley' and t1.FIRST_NAME='William', t2.LAST_NAME='Weasley'.
Also.
I need to use N, because as i said the columns are type of NVARCHAR and i have non-ASCII letters there, so for example:
SELECT * FROM T1 WHERE CODE = 'Неважно' retruns nothing, to fix this i have to add N: SELECT * FROM T1 WHERE CODE = N'Неважно' returns a row.