Stored Procedures [dbo].[MssWebInsertSakariContactSysUser]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inSysUserIdint4
@inOrderIdint4
@inContactPriKeyint4
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
create procedure [dbo].[MssWebInsertSakariContactSysUser]
    @inSysUserId int,
    @inOrderId int,
    @inContactPriKey int
as
begin

    insert into SakariContactSysuserMap
    (
        SysuserFID,
        SakariContactFID,
        LastReadAt
    )
    select
    @inSysUserId,
    @inContactPriKey,
    sysdatetimeoffset()
    where not exists
    (
        select
        top 1 1
        from
        SakariContactSysuserMap
        where SysuserFID = @inSysUserId
        and SakariContactFID = @inContactPriKey
    )

    insert into SakariContactOrderMap
    (
        OrderFID,
        SakariContactFID
    )
    select
        @inOrderId,
        @inContactPriKey
    where not exists
    (
        select top 1 1
        from SakariContactOrderMap
        where
            OrderFID = @inOrderID and
            SakariContactFID = @inContactPriKey
    )
end
GO
GRANT EXECUTE ON  [dbo].[MssWebInsertSakariContactSysUser] TO [MssExec]
GO
Uses