I have two tables aspnet_Membership and aspnet_Users. I want to remove all of the records from both tables that are older than 30 days by using a single stored procedure.
So far I have this:
BEGIN BEGIN TRY BEGIN TRANSACTION DELETE FROM aspnet_Membership WHERE CreateDate < DATEADD(DAY, -30, GETDATE()) COMMIT TRAN END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK TRAN END CATCH END
but I cannot figure out how to also delete the same, or matching, records in the aspnet_Users table because is does not have a CreateDate column. Both tables do have a UserId column, can someone please show me how to do this?