Join in Update/Delete Statement in SQL Server

Update Statement
UPDATE t1
SET t1.TargetCol1 = t2.SourceCol1,
t2.TargetCol2 = t2.SourceCol2
FROM Table1 AS t1
INNER JOIN Table2 AS t2 ON t2.PrimaryCol = t1.PrimaryCol

Delete
DELETE TB1 FROM Table1 TB1 INNER JOIN StagingTable ON Table1.Field2 = StagingTable.Field2

Comments

Popular posts from this blog

മലയാളത്തില്‍ മൊത്തം എത്ര അക്ഷരങ്ങള്‍ ഉണ്ട്?

Convert Number To Words in SQL Sever

Crystal reports load report failed: Could not load file or assembly CrystalDecisions.Web, Version=10.2.3600.0