[dbo].[MssWebUpdateSakariContactLastReadAt]
CREATE procedure [dbo].[MssWebUpdateSakariContactLastReadAt]
@inContactId int ,
@inSysUserId int
as
begin
;with insertUpdateSakariContactSysuserMap as
(
select
SysuserFID = @inSysUserId,
SakariContactFID = @inContactId
)
merge SakariContactSysuserMap with (tablock)
using insertUpdateSakariContactSysuserMap on
SakariContactSysuserMap.SysUserFID = insertUpdateSakariContactSysuserMap.SysuserFID and
SakariContactSysuserMap.SakariContactFID = insertUpdateSakariContactSysuserMap.SakariContactFID
when matched then
update set
LastReadAt = sysdatetimeoffset()
when not matched then
insert
(
SysuserFID,
SakariContactFID,
LastReadAt
)
values
(
insertUpdateSakariContactSysuserMap.SysuserFID,
insertUpdateSakariContactSysuserMap.SakariContactFID,
sysdatetimeoffset()
);
end
GO
GRANT EXECUTE ON [dbo].[MssWebUpdateSakariContactLastReadAt] TO [MssExec]
GO