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 |
|
raghuveer125
Constraint Violating Yak Guru
285 Posts |
Posted - 2011-03-25 : 05:54:04
|
| I need to calculate dynamic formula changeDummy valuesCreate table #A (id int,product nvarchar(25),values int)insert into #A values ('1','Book','25')insert into #A values ('2','Pen','30')insert into #A values ('3','Eraser','10')Formula Tablecreate table #Formulatable (FormulID int,FormulaName nvarchar(25),Formula nvarchar(max))insert into #Formulatable ('1','FirstFormul','Book+Pen-Eraser')insert into #Formulatable ('2','SeconFormul','Book+Pen*Eraser')This above formula work fine for mebut when user update or change Formula likeupdate #Formulatable set Formula='Book+Pen-Eraser*SeconFormul' where FormulaID=1See in #Formulatable FormulaID 1 is updated by user and formula changed.This formula now having 2 level means formula with one more formula. How to solve this problem.If this problem solved then I need n level calculation (/*This all calculation done on flay so I am not going to save this calculated value in any other table*/)Raghu' S |
|
|
TheDarkPassenger
Starting Member
1 Post |
Posted - 2011-03-25 : 12:43:34
|
| Looks like you're making this difficult for yourself.Ensure another formula line is created that hasBook+Pen-Eraser * Book+Pen*Eraserand place a unique constraint on the Formula column to stop people entering duplicates.HTH |
 |
|
|
raghuveer125
Constraint Violating Yak Guru
285 Posts |
Posted - 2011-03-28 : 08:29:29
|
| ActuallyIn formula table Formula name is fixedso we can't add any other additional row each time when formula edited through front-end.Again in Formulatable column FormulaName is fixed user can edit only Formul. (Note:1= Actually I have more than 90 formulas in that many formula have sub formulas like Example1 st Formula Sum = A+B (where A and B are column of table)2 nd Formula Sub = A-C (-------------do----------------)3 rd Formula Mul = Sum*Sub ( Here sum is 1st fomrul and sub is 2nd))In future user can change formulaas 1 st Formula Sum = D+C or D-C depending upon his requirementso this is fully calculation based project. Note :2And this is on flay calculation so I am not going to store this result in any tableRaghu' S |
 |
|
|
|
|
|
|
|