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 |
Angel0in
Starting Member
4 Posts |
Posted - 2009-02-23 : 16:23:46
|
Hello to all helpers,I have a table in database:Create table TestTable (GroupId int, ANumber int)with samle data :GroupId ANumber------------------- 1 10 1 70 1 20 2 60 2 40 3 35 3 40 3 15 3 10My Buisness Rule requirement is : Keep Group Total to 100like for Group 1 >> 10+70+20=100Group 2 >> 60+40=100Group 3 >> 35+40+15+10=100Is it possible to use some constraint ( but it is single row level) ?How to implement this buisness rule on SQLServer ?Thanks |
|
mfemenel
Professor Frink
1421 Posts |
Posted - 2009-02-23 : 16:27:56
|
Sounds like a good candidate for a check constraint or a trigger.Mike"oh, that monkey is going to pay" |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-23 : 16:44:58
|
You can use scalar function to calculate sum and use it in check constraint. |
|
|
Angel0in
Starting Member
4 Posts |
Posted - 2009-02-24 : 11:51:12
|
Thanks mfemenel and sodeep |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-24 : 12:19:52
|
Welcome |
|
|
|
|
|