Prev: Linked Server Hanging
Next: Join via srting of integers
From: DavidC on 28 Apr 2010 12:11 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 28 Apr 2010 22:32 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
|
Pages: 1 Prev: Linked Server Hanging Next: Join via srting of integers |