[dbo].[MssWebGetOrderUnreadAndScheduledCount]
create procedure [dbo].[MssWebGetOrderUnreadAndScheduledCount]
@inOrderId int,
@inSysUserId int
as
begin
set nocount on
set nocount on
select
UnreadCount = isnull(Sum(Data.UpdateCount),0) ,
ScheduledCount = isnull(Sum(Data.ScheduledMessageCount),0)
from UdfGetUnreadAndScheduledMessageCount(@inSysUserId) Data
inner join SakariContact on Data.ContactID = SakariContact.SakariContactID
left outer join SakariContactOrderMap on Data.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