Found at:
-----
Q: SET or SELECT -- is there any performance difference?
A:There isnt any performance difference.But SET is the standard assignment syntax.
For example, consider this subquery:
SET @variable = (SELECT columnvalue FROM dbo.tablename)
Here, if the results of the subquery expression is empty then @variable has a value of NULL but
if results of the subquery are more than one row then you get a error.And thus it makes sense while
SELECT @variable = columnvalue FROM dbo.tablename
returns a value from a number of rows and we are not sure whats the criteria in selecting that row!
Also, for ease of programming SELECT is anyways used as SQL syntax to retrieve rows.Thus it makes it easier to have SET for assigning.One major difference in assigning using SET and SELECT is:
SET @variable1 = 'somevalue', @variable2 = 'someothervalue'
This is NOT possible but the same is possible with SELECT as in:
SELECT @variable1 = 'somevalue', @variable2 = 'someothervalue'
-----
Hope this helps.
Glen Appleton
VB.Net student.