简体   繁体   中英

SQL Server 2008: update query

I have TableA with FKColumnID

I also have TableB with ColumnID and ColumnName

How can I update TableA.FKColumnID to have the same value as tableB.ColumnName ?

Update TableA
Set TableA.ColumnName = TableB.ColumnName

You can try this

UPDATE TableA
SET ColumnName = TableB.ColumnName
FROM TableA
JOIN TableB on TableA.FKColumnID = TableB.ColumnID
WHERE < any additional criteria >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM