Search this insane blog:

Saturday, December 19, 2009

What is the difference between SET and SELECT variables

If you have a set, you know for sure it will return only one value.

if you use SELECT to set a variable:
select @myVariable = myTable.MyCol


or..

if you use the SET statement to set a variable

set @myVariable = myTable.MyCol


At certain times, with the SELECT statement, you can return more than one row.

That so much a problem?
Well, I think it potentially could be.
There can be no error that is returned when you get multiple rows.

here is a good source:
http://www.mssqltips.com/tip.asp?tip=1888

No comments:

Post a Comment