I have two tables
Table1
REF1 REF2
A
B
C
Table2
UPN Filename
1 A
2 B
3 C
what I want to do in SQL is this
If Table1 REF2 = Table2 Filename then set Table1 REF1 = Table2 UPN
this is the sql I did
UPDATE Table1
SET REF1 = Table2.UPN
FROM Table1 INNER JOIN Table2
ON Table1.REF2 = Table2.FileName
all this does is take the first value in row 1 of table2 and put it in every row under table1 in REF1
eg this is what I get
TABLE1
REF1 REF2
1 A
1 B
1 C
this is what I want
TABLE1
REF1 REF2
1 A
2 B
3 C
any help appreciated.
To do this in SQL Server, here is the syntax: