Hello,
Thank you so much for your replies!!!
"I would hope is being deprecated and that's why nobody thought to mention it in a guide is supposed to be teaching people how to write decent SQL." - but the Select = @VAR is mentioned in the textbook, it is the 'EXEC @VAR = sp...' that is not !
"The use of the set syntax is ANSI/ISO standard SQL and you should use it if you want your code to be readable and portable" - I also prefer using the SET method!
"There is a fifth way that a variable can be assigned a value. Can you spot it? (Hint: that also includes the EXEC statement.)" - I can just suppose this is the using of the output parameters in the stored procedures (spname @param1, @param2 OUTPUT).
"or decided that it was more pedagogical to keep quiet about this option, which after all is quite a special case." - oh yes, that was a great pedagogical technique: to illustrate the 2 ways to assign a value (3 with the DECLARE) and post the link to the page (right above the picture I've posted above) that describes the totally different way :)))
"Maybe this little difference was the reason why the author didn't mention the EXEC way in the notebook." - yes, maybe that was the reason, but the problem is that this chapter - along with the lesson on variables - contains information about using the Control-of-Flow Language and the RETURN keyword in particular, but does not explain how to receive the value of the RETURN and if I hadn't spotted the example with the 'EXEC @return _status = checkstate '2'; ' I wouldn't have known how I could get that return value because - as MelissaMa-msft and my textbook have mentioned - only 3 methods exist and there is no EXEC @VAR ... method, so my question can be reformulated in the following way: can I assign the return sp value to a variable using only the 3 methods posted above (WITHOUT using OUTPUT parameters)?
Regards,
Michael