954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Can some one please help me!

i m using sql 2000 and i have a table with 3 columns ( credit , debit, total)
what i want to do is whenever a value is inserted to the credit column it should add that amount to the total column and whenever there is a debit value it should Subtract from the total value
can some one please help me with this
i know this should be done by a rule but i cant figure out how to do it

kalpa23
Light Poster
41 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

Is Total supposed to be a running sum or is it simply the current total as reflected by the current credit and debit amounts?

In either case, I would look up triggers and modify your Total value whenever a row as updated.

apegram
LINQ!
Team Colleague
552 posts since Jan 2010
Reputation Points: 327
Solved Threads: 135
 

it should be current total

kalpa23
Light Poster
41 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 
it should be current total

The you can simply say

Update tableNameHere Set Total = Credit - Debit


As I said before, you should look up triggers in SQL Server 2000 to see how you can associate the aforementioned statement with a table as a record gets updated.

I assume there is a valid reason for storing a calculated value in the table when a simple query would do. I suppose that's just part of the assignment, huh?

apegram
LINQ!
Team Colleague
552 posts since Jan 2010
Reputation Points: 327
Solved Threads: 135
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: