I just found the following code inside a stored procedure.
BEGIN
SELECT @MyVar = MyField
FROM ...
-- do something with @MyVar
END
The problem is that the query could return more than one row (not just a theoretical possibility, I know this might happen). What would happen if the query returned more than one row?
The value in @MyVar would reflect the value of MyFIeld of last row returned by the query.
No, but again depends on the rest part of the query.