From: DavidC on
Is there any difference in setting a declared variable value using SET or
SELECT? See example below as both get the same result. Thanks.

DECLARE @Branch int;
SELECT @Branch = Branch FROM dbo.PeopleLink WHERE PeopleLinkID =
@ClientLinkID;
-or-
SET @Branch = (SELECT Branch FROM Branches WHERE PeopleLinkID =
@ClientLinkID);
--
David
From: Plamen Ratchev on
In addition to John's comment, one of the differences that matters most is when you have multiple rows returned by the
query (most likely this is discussed in the links John posted, but in my opinion worth pointing out). In that case
SELECT will assign non-deterministically one value, while SET will result in error. I prefer using SET to detect such
cases.

--
Plamen Ratchev
http://www.SQLStudio.com