January 30, 2020 at 12:00 am
Comments posted to this topic are about the item Assignment of a value to a variable
January 30, 2020 at 7:55 am
That's correct: "an empty result set preserves the existing value of the variable", NO result set, NO assignment. In the case of SET or SELECT with a subquery (as shown below), it acts as an expression that always returns a value or NULL.
SELECT @j-2 = (SELECT j FROM #John WHERE 1=0);
SET @j-2 = (SELECT j FROM #John WHERE 1=0);
January 30, 2020 at 9:21 am
Nuts! I wasn't paying attention.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 30, 2020 at 9:25 am
Since answer 2 and 5 are the same, they can't be the correct answer. So that leads almost automatically to the right answer.
January 30, 2020 at 12:43 pm
I was curious that 2 and 5 were the same. But that, in itself, doesn't make them wrong.
January 30, 2020 at 1:36 pm
It has happened once before that identical answers were correct. People who picked the "wrong" correct answer were later credited.
January 30, 2020 at 3:00 pm
Yeah, if we screw it up, we try to make it right.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 30, 2020 at 5:06 pm
Thanks, everybody, for your feedback. I don't know how I managed to have the same answer twice, and it's six weeks now since I submitted the question. I probably copied and pasted it but then forgot to edit it, or something. Lucky I didn't omit the correct answer! And I managed to let a typo into the final option as well.
John
January 30, 2020 at 8:56 pm
Great question, thanks John. Some typo doesn't matter, and the same two answers don't. After all, one correct answer rules out the remaining... Thanks also to Carlo Romagnano for clarifying that the use of SET or SELECT with a subquery always returns a value or NULL.
George
January 31, 2020 at 5:53 am
Nice question, thanks John
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
February 3, 2020 at 9:26 pm
Nice question, thx John!!
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply