I have a database with account numbers
and card numbers
. I match these to a file to update
any card numbers to the account number, so
I thought this is a simple example might someone get it easier,
DECLARE @TB1 TABLE
(
No Int
,Name NVarchar(50)
)
DECLARE @TB2 TABLE
(
No Int
,Name NVarchar(50)
)
INSERT INTO @TB1 VALUES(1,'asdf');
INSERT INTO @TB1 VALUES(2,'awerq');
INSERT INTO @TB2 VALUES(1,';oiup');
INSERT INTO @TB2 VALUES(2,'lkjhj');
SELECT * FROM @TB1
UPDATE @TB1 SET Name =S.Name
FROM @TB1 T
INNER JOIN @TB2 S
ON S.No = T.No
SELECT * FROM @TB1