Stored Procedures [dbo].[MssWebUpdateSakariContactLastReadAt]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inContactIdint4
@inSysUserIdint4
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
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
Uses