Hi, All,
We have many inactive customers bloating the database, is there is a simple method to delete them with using SQL, I noticed there are many relationships between tables that make this harder to do?
Paul.
-- UPDATE ALL REGISTERED CUSTOMERS WHO ARE INACTIVE AND MAKE THEM GUESTS
UPDATE crm
SET crm.CustomerRole_Id = 4 -- GUESTS
FROM dbo.Customer_CustomerRole_Mapping AS crm
INNER JOIN dbo.Customer AS c
ON crm.Customer_Id = c.Id
WHERE c.Active = 0
-- Date in the past, keep recent customers, last 2 weeks as an example
AND c.LastActivityDateUtc < -- [ADD DATE]
SELECT *
FROM [ClickAlgo_41].[dbo].[Customer] c
INNER JOIN dbo.Customer_CustomerRole_Mapping AS crm
ON crm.Customer_Id = c.Id
where c.active = 0
and crm.CustomerRole_Id = 4;