• Slightly puzzled how you got those procedure to work, are you certain that you posted the right code? Quickly looking at the first procedure:

    1. Typo, flaot should be FLOAT, this will never work.

    2. Missing variable declaration for the @query variable, will error.

    3. 'distinct' directive in a wrong place, this will never work.

    4. Missing FROM clause, this will never work.

    No need to go any further until this is fixed. My suggestion to you is to describe as accurately WHAT you are trying to achieve and we will help you with HOW to do it.

    😎