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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Its abt updting a column based on another column in same tbl

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-06-20 : 07:17:39
kay writes "hey wass'up ?
i am a beginner in sql server 2000. i designed a small database
named "Soccer" with 3 tables in it namely , 'Players', 'Clubs' & 'Results'. i wrote a trigger on 'Results' table to update [Points] column in 'Players' table and 'Clubs' table respectively. It Fired well, the [Points] column got updated. There is another column named [Position] in 'Players' table which i want to update and re-order based on the descending order of updated [Points] column . How Can i do it ? plz help me .

Note : The 'Players' & 'Clubs' Table already contains data."

Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-06-20 : 08:53:19
I assume position has to do with a players total points. I was always taught to not store calculated values. Why not just write a stored procedure that your application calls when you need to know the rank of the players with regards to their scoring prowess.

Sean Roussy

Please backup all of your databases including master, msdb and model on a regular basis. I am tired of telling people they are screwed. The job you save may be your own.
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2005-06-20 : 09:40:51
Indeed. Surely there is no need to store the "position" as it is entirely dependant on other known values, you can just ORDER BY the known values.

-------
Moo. :)
Go to Top of Page

Incredibles
Starting Member

1 Post

Posted - 2005-06-21 : 13:39:25
hey,
Thanks For ur reply.
I guess u lads didnt get me. All i want is to update my position column as my points columns gets updated. say for example, if Mr A has 10 points and he is in position one and Mr B in second with 8 points. Mr B won a match and his points gets increased to 18 points. All i want is , Mr B should move-up and his position column should gets updated automatically(say first) and Mr A should come down and his position in position column should change from 1 to 2 ( automatically ). moreover the position column is not identity column nor primary key one( bcos 2 players can share same position with same points ). i want to keep my position column for a simple reason tht some other person can have a clear view abt my database. plz help me out with solution

cheers !!!
Thanks a million
kay.

Go to Top of Page

Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-06-21 : 14:23:09
No we got your point. We just think it is better practice to do this in your query for your application instead of in your tables. I do'nt always give you what you ask for but I always give what you need. If you post you DDL and what your outout looks like I will show you what I mean.

Sean Roussy

Please backup all of your databases including master, msdb and model on a regular basis. I am tired of telling people they are screwed. The job you save may be your own.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-06-21 : 14:33:55
quote:
Originally posted by Incredibles

plz help me out with solution



Follow the instructions in the link below



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -