[dbo].[GetExistingConversations]
create procedure [dbo].[GetExistingConversations]
@inSysUserPriKey int,
@inOrderPriKey int
as
begin
set nocount on;
select
Name = SakariContact.ContactName,
Phone = SakariContact.PhoneNumber,
ContactPriKey = SakariContact.SakariContactID,
UserIsSubscribedToContact = convert(bit, isnull(SakariContactSysUserMap.Subscribed,0))
from SakariContactOrderMap
inner join SakariContact on
SakariContact.SakariContactID = SakariContactOrderMap.SakariContactFID
left outer join SakariContactSysuserMap on
SakariContact.SakariContactID = SakariContactSysuserMap.SakariContactFID and
SakariContactSysuserMap.SysUserFID = @inSysUserPriKey and
SakariContactSysuserMap.Subscribed = 1
where dbo.SakariContactOrderMap.OrderFID = @inOrderPriKey
end
GO
GRANT EXECUTE ON [dbo].[GetExistingConversations] TO [MssExec]
GO