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 |
|
lloydnicholson
Starting Member
5 Posts |
Posted - 2002-09-23 : 07:23:24
|
| I have a problem...I have two tables - tblleaderboardID intName varcharDate datetimeTotal decimalPrize varcharAnd tblprizesID intPRIZE varchar PRIZE_DESC varcharIMAGE_URL varchartblleaderboard changes every 1-2 seconds because new values are entered. What I want to achieve is to UPDATE tblleaderboard.prize from tblprizes.prize Ordered by ID (the top prize has an id of one and so on) starting with the highest total in tblleaderboard and looping until the prize table has been inserted to into the corresponding row on the tblleaderboard. The problem is there is nothing to relate the two tables because the row with the highest score changes from second to second. This update has to be a stored proccedure!I hope I have explained myself fully.Many thanks,Lloyd |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-09-23 : 07:32:04
|
| If you want the leaderboard to be in step with prizes then you will have to do it in a trigger.something like.create trigger tr on tblprizes for insert, update, deleteasif exists(select * from inserted)update tblleaderboardset prize = i.prizefrom tblleaderboard lb, inserted iwhere lb.id = i.idelseupdate tblleaderboardset prize = nullfrom tblleaderboard lb, deleted dwhere lb.id = d.idgo==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|