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
 General SQL Server Forums
 New to SQL Server Programming
 need help

Author  Topic 

poornima
Starting Member

32 Posts

Posted - 2006-11-11 : 05:42:07
In my previous post i mentioned i have a table with columns
Date datetime,Particulars varchar(60),Credit numeric(15,2),Debit numeric(15,2),Debit numeric(15,2),Balance numeric(15,2)

Now my requirement is to update the Balance column dynamically.Like as when i update the database with credit ,debit entries,the balance col should get updated like if Credit ,balance = balance+Credit
if debit balance=balance-Debit .
Please tell me if its possible.

Also plz tell me some simple projects in sql that also involves ADO.net.(eg payrolls)

In payrolls plz tell me wht r requirements so tht i can design the db accordingly
Thanks In Advance
Poornima

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-11 : 06:12:18
What do you mean you want to update Balance column dynamically?

Why don't you update it explicitly?

Something along these lines:

Update Tbl
Set Balance = (case EntryType
when 'DR' then balance - debit
when 'CR' then balance + credit
end)



Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

poornima
Starting Member

32 Posts

Posted - 2006-11-11 : 06:19:51
I meant that i want to update it as n when i enter the credit n debit values it should also get updated by not giving the specified query for each debit/credit entry.

Can i get my reqmt if do using ADO.net
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-11 : 06:25:58
In that case the option is obviously writing an UPDATE trigger.

But again the question is when you are going to enter debit or credit values, at the same time and in the same query, why don't you just update balance field as well?

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page
   

- Advertisement -