Stored Procedures [dbo].[MssWebGetOrderUnreadAndScheduledCount]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inOrderIdint4
@inSysUserIdint4
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
CREATE procedure [dbo].[MssWebGetOrderUnreadAndScheduledCount]
    @inOrderId int,
    @inSysUserId int
as
begin
    set nocount on
    declare @subscribedOnly bit  = 0;
    select
        UnreadCount = isnull(Sum(ContactMessagesCount.UpdateCount),0) ,
        ScheduledCount = isnull(Sum(ContactMessagesCount.ScheduledMessageCount),0)
    from [dbo].udfGetUnreadAndScheduledMessageCount(@inSysUserId,@subscribedOnly) ContactMessagesCount
    inner join SakariContact on ContactMessagesCount.ContactID = SakariContact.SakariContactID
    left outer join SakariContactOrderMap on ContactMessagesCount.ContactID = SakariContactOrderMap.SakariContactFID
    inner join SakariAccount on SakariContact.SakariAccountFID = SakariAccount.SakariAccountID
    inner join Orders on SakariContactOrderMap.OrderFID = Orders.PriKey
    where SakariContactOrderMap.OrderFID = @inOrderId
end
GO
GRANT EXECUTE ON  [dbo].[MssWebGetOrderUnreadAndScheduledCount] TO [MssExec]
GO
Uses