Update table value by matching records between two tables

When a temporary Table holds a list of records to update, and another Table holds the complete record list, an JOIN can be used to filter the records


UPDATE PrimaryTable

SET PrimaryTable.Field = 'SomeValue'

FROM PrimaryTable

INNER JOIN TempTable ON TempTable.Column_To_Match = PrimaryTable.Column_To_Match

WHERE Condition_To_Filter_TempTable_Further

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