I have the following table
create table bufScan
(
msgid int,
conversationid nvarchar(max),
mailbox nvarchar(max)
);
INSERT dbo.bufScan VALUES
(1,'person1@company.com','AAQkAGIwZjk4OTk4LTRkZGYtNDM5Yi04NGZlLTAzMDY1MjQ3ZjVlMgAQAPX8hFCq30h3robsMxenwt8='),
(2,'person1@company.com','AAQkAGIwZjk4OTk4LTRkZGYtNDM5Yi04NGZlLTAzMDY1MjQ3ZjVlMgAQAESPK731aUirpd0CyOIlR5I='),
(3,'person1@company.com','AAQkAGIwZjk4OTk4LTRkZGYtNDM5Yi04NGZlLTAzMDY1MjQ3ZjVlMgAQAESPK731aUirpd0CyOIlR5I='),
(4,'person1@company.com','AAQkAGIwZjk4OTk4LTRkZGYtNDM5Yi04NGZlLTAzMDY1MjQ3ZjVlMgAQAPX8hFCq30h3robsMxenwt8='),
(5,'person2@company.com','AAQkADhlYTk5MGY1LTJkOTUtNDVjNy1iNDg0LTljYjc5ODAzZTM3OQAQAPX8hFCq30h3robsMxenwt8='),
(6,'person2@company.com','AAQkADhlYTk5MGY1LTJkOTUtNDVjNy1iNDg0LTljYjc5ODAzZTM3OQAQAESPK731aUirpd0CyOIlR5I='),
(7,'person2@company.com','AAQkADhlYTk5MGY1LTJkOTUtNDVjNy1iNDg0LTljYjc5ODAzZTM3OQAQAESPK731aUirpd0CyOIlR5I='),
(8,'person2@company.com','AAQkADhlYTk5MGY1LTJkOTUtNDVjNy1iNDg0LTljYjc5ODAzZTM3OQAQAX8hFCq30h3robsMxenwt8=');
Let us assume that AAQkADhlYTk5MGY1LTJkOTUtNDVjNy1iNDg0LTljYjc5ODAzZTM3OQ
and AAQkAGIwZjk4OTk4LTRkZGYtNDM5Yi04NGZlLTAzMDY1MjQ3ZjVlMg
are entries that give us information for a specific mailbox and AX8hFCq30h3robsMxenwt8=
and AESPK731aUirpd0CyOIlR5I=
for a specific conversation.
In this example, person1 is having conversations with person2.
I would like to keep all conversation from only one mailbox, otherwise, it will be like having double conversations in my data. That means that i would like to keep entries for AX8hFCq30h3robsMxenwt8=
and AESPK731aUirpd0CyOIlR5I=
either from AAQkADhlYTk5MGY1LTJkOTUtNDVjNy1iNDg0LTljYjc5ODAzZTM3OQ
or AAQkAGIwZjk4OTk4LTRkZGYtNDM5Yi04NGZlLTAzMDY1MjQ3ZjVlMg
. I hope I made it more specific.
Since I want to keep also information about all messages that are part of the conversation I don't want to delete duplicates that have different message id in the same partition of the mailbox.