Stuart McLachlan
stuart at lexacorp.com.pg
Wed Sep 14 02:48:04 CDT 2011
On 14 Sep 2011 at 2:32, Arthur Fuller wrote: > Yeah OK I get it, I'm way out of the loop. But catch me up, please. I > still don't understand why or how this works. > > If you have a spare moment, please explain. > It's actually quite simple once you dig through the obfuscation. You don't need the DECLARE and PRINT lines at all to return the recordset in question, They just returning the string "Result = Null" as an "informational error message" to the calling application. (Null because although @b is declared, it is not initialised with a SET @b =....." ) The recordset comes purely from the select part which is just using different ways of declaring field aliases and using concatentation of +/- operators..You get exactly the same recordset returned with: SELECT 0 AS A, 1 - (-1) AS B, 1 + (+1) AS C, 1 + (- (+1)) AS D, 1 - (+ ( -1)) AS E, 1 - (-1) AS F or SELECT A = 0, B = 1 - (-1), C = ..... Note the field alias B is not the integer variable @b. Using the same letter for both is just further obfuscation.