Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
harshal_in
Aged Yak Warrior
633 Posts |
Posted - 2003-06-05 : 07:08:49
|
| what is the difference between select @variable = columnName from tablenameandset @variable=(select columnName from tablename)Regards,Harshal.The Judgement of the Judge is as good as the Judge. |
|
|
dsdeming
479 Posts |
Posted - 2003-06-05 : 08:26:31
|
About 6 keystrokes. Seriously, although they'll both get you the same data, take a look at the execution plans. They're very different.Dennis |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-06-05 : 08:50:59
|
| I could be wrong, but i think:select @var = col from tablewill always return the LAST col if there is more than 1 row returned from the select statement.I would thinkset @var = (select ....)would return the FIRST. could be wrong.EDIT: just checked it out. The second is NOT valid if more than 1 row is returned from the (SELECT ...) statement. There's your difference.- JeffEdited by - jsmith8858 on 06/05/2003 08:52:52 |
 |
|
|
harshal_in
Aged Yak Warrior
633 Posts |
Posted - 2003-06-05 : 09:11:40
|
quote: I could be wrong, but i think:select @var = col from tablewill always return the LAST col if there is more than 1 row returned from the select statement.I would thinkset @var = (select ....)would return the FIRST. could be wrong.EDIT: just checked it out. The second is NOT valid if more than 1 row is returned from the (SELECT ...) statement. There's your difference.- JeffEdited by - jsmith8858 on 06/05/2003 08:52:52
I agree.I wanted to know performance wise .thanks for the reply to both of u.regards,Harshal.The Judgement of the Judge is as good as the Judge. |
 |
|
|
|
|
|