[SQL Server] Copy data between rows of the same table
How do you solve the problem of copying data from the same column between two existing rows of the same table, in Microsoft SQL Server 2000?
The answer is UPDATE ... FROM:
UPDATE tbl SET val = b.val
FROM tbl, tbl b
WHERE tbl.primaryKey=pk1 AND b.primaryKey=pk2
The syntax may seem a bit weird... but it works.
The answer is UPDATE ... FROM:
UPDATE tbl SET val = b.val
FROM tbl, tbl b
WHERE tbl.primaryKey=pk1 AND b.primaryKey=pk2
The syntax may seem a bit weird... but it works.