A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
use the merge statement
merge MyTable t
using (select @col1, @col2) as s (col1, col2)
on t.col2 = s.col2
when matched then
update set col1 = s.col1
when not matched then
insert (col1, col2)
values (s.col1, s.col2)