I am trying to change my current query to say, if x exists, then update values, otherwise just insert into table.
Right now my query is something like
with t1 as
(
select * from table
)
insert into existingTable
How do I add an IF EXISTS
, then UPDATE
values, if not INSERT INTO
.
I am trying not to have the WITH
statement twice because it is very long.
Any ideas?