Insert or Update
Версия 2.1 от Alexandr Fokin на 2020/03/21 22:17
Declare @key int = 12
Declare @msg nvarchar(max) = 'L2'
begin tran
if exists (
select *
from dbo.Log2Entity with (updlock,serializable)
where ID = @key
)
begin
update dbo.Log2Entity
set
Message = @msg
where ID =@key
end
else
begin
insert into dbo.Log2Entity (Message)
values (@msg)
end
commit tran