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 |
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2003-11-10 : 17:15:55
|
Hi,If I have...SELECT @variable = Field1FROM table1ORDER BY Field1 and table1 has multiple items in it, do I always get the last record in the restult set's value for Field1?X-Factor |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2003-11-10 : 17:24:15
|
| Order by Field 1 determines the value of @variable. asc then last record, desc the first. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-11-10 : 17:25:11
|
| Yes you'll always get the last record as long as you provide an ORDER BY statement.Tara |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-11-11 : 12:29:46
|
| ...and it has to a lot more work...Why not just doSELECT TOP 1 @variable = Field1FROM table1ORDER BY Field1 DESCBut there seems a larger issue here...Brett8-) |
 |
|
|
|
|
|