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 |
|
Xorbit
Starting Member
3 Posts |
Posted - 2009-01-04 : 16:12:26
|
| Hi,I keep track of my own "rank" property to have my lists sorted the right way.I have a lot of inserts where I want to insert a post with "rank" to be the highest allready in the table +1.Is there a smart way to do this or do I have to make a select statement first to select out to my ASP what is the max(rank) and then insert it?I have tried something likeINSERT INTO table (att1, ranken) VALUES ('1', max(ranken)+1);But that doesn't work out.Best regardsKlaus |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-01-05 : 02:19:36
|
| INSERT INTO table (att1, ranken)SELECT '1', COALESCE(MAX(ranken),0) + 1FROM tableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|