SQL Database consistency errors and resolution