I'm hoping to develop a query that will delete all users and records in other related tables which are in the role of trial.
The following query gets all my trial users:
SELECT u.UserName, ur.RoleId, r.RoleName, p.UserId
FROM aspnet_Users u INNER JOIN
aspnet_UsersInRoles ur ON u.UserId = ur.UserId AND u.UserId = ur.UserId INNER JOIN
aspnet_Roles r ON ur.RoleId = r.RoleId AND ur.RoleId = r.RoleId INNER JOIN
aspnet_Membership p ON u.UserId = p.UserId AND u.UserId = p.UserId
WHERE (r.RoleName = N'Trial')
I need to delete the relevant records in aspnet_Users, aspnet_UsersInRoles and aspnet_Membership tables. Any help in figuring out how to do this greatly appreciated.