• A bit complicated code, what are you trying to do?

    why do you try running a function from a stored procedure after passing a value form the Exist statement