I think you can make a SQL Trigger in your SQL database to be triggered when a special event is occurring or if you have access to the DataServer source code, you can do the UPDATE when the level up event is happening. This way you don't need to always execute the UPDATE query which you are trying to use. Search for SQL Trigger syntax and try to understand how to create one for your database.
It can be something like
Code:
DROP TRIGGER IF EXISTS check_max_stats;
GO
CREATE TRIGGER check_max_stats ON [MuOnline].Characters AFTER UPDATE
AS BEGIN
DECLARE @ AccID INT;
DECLARE @ Strength INT;
DECLARE @ Dexterity INT;
DECLARE @ Vitality INT;
DECLARE @ Energy INT;
DECLARE @ Leadership INT;
DECLARE @ maxstatPoints INT;
SET @ maxstatPoints = 80000;
SELECT @AccID= updt.AccountID FROM UPDATE updt;
SELECT @ Strength = updt.Strength FROM UPDATE updt;
SELECT @ Dexterity = updt.Dexterity FROM UPDATE updt;
SELECT @ Vitality = updt.Vitality FROM UPDATE updt;
SELECT @ Energy = updt.Energy FROM UPDATE updt;
SELECT @ Leadership = updt.Leadership FROM UPDATE updt;
IF ( @ Strength + @ Dexterity + @ Vitality + @ Energy + @ Leadership) > @ maxstatPoints
//DO SOMETHING WHEN SUM IS HIGHER THAN MAXSTATPOINTS
ELSE
THROW51000,'Error: Can not update character',1;
END;
Sorry for the format. The forum doesn't allow me to use some specific annotations under CODE tag. Delete the space between @ and variable name.
Most importantly is to get the idea from it.