SQL – Joined Update – Table update With A Join

 

The following joined update updates a table called data.dbo.table1 from a table called data.dbo.table2 and sets the fielda in table1 equal to fielda in table2 based on a matching ref:

updatedata.dbo.table1

      setfielda = b.fielda

fromdata.dbo.table1 as a

joindata.dbo.table2 as b

on a.ref = b.ref

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s