dbexec ms sql insert / update transaction

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
bbrink
Pro Scripter
Posts: 54
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

dbexec ms sql insert / update transaction

Post by bbrink » Sat Mar 23, 2019 12:06 pm

Hello,

I have code shown below and want to send it to MS SQL server via DBEXEC. How can this be done?

[snippet=]
begin tran
if exists (select * from table with (updlock,serializable) where key = @key)
begin
update table set ...
where key = @key
end
else
begin
insert into table (key, ...)
values (@key, ...)
end
commit tran
[/snippet]

Thanks in advance,

Bob

Post Reply