Skip to content

Instantly share code, notes, and snippets.

@alexdwhite
Created March 18, 2018 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexdwhite/0d0a49279fadaacb7b13909eda0d4006 to your computer and use it in GitHub Desktop.
Save alexdwhite/0d0a49279fadaacb7b13909eda0d4006 to your computer and use it in GitHub Desktop.
I wrote a joined updated statement today, and figured it would be good to get some generic code up here to reference in the future. Here is how to do a simple update that updates the values of one table, to another on a common key.
update
a
set
a.Field1 = b.Field1,
a.Field2 = b.Field2
from tableA a
inner join tableB b on a.fKey = b.pKey
where a.pKey = @someValue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment