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
 Calculate Formulae

Author  Topic 

svallamreddy
Starting Member

4 Posts

Posted - 2007-06-29 : 07:23:17
Hi,

In a table there is a column as Formulae varchar(50), When the data getting inserted column can have data as "(TP*12.00)+12". So in procedure user send in parn TP value.

First of all the TP has to be replaced with In parn value, then procedure need to value then return final value.

For Ex:
TP [In Parn] = 1.5

"(TP*12.00)+12" => (1.5*12.00)+12
return value as 30

pl. help how can I achieve this,

Thanks
Sreenu

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-29 : 07:33:41
It's not going to be easy. You either have to build your own parser or use dynamic sql exec() to do it.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-29 : 07:40:44
Only way is using Dynamic sql
declare @data varchar(50)
select @data='(TP*12.00)+12'
select @data='select '+replace(@data,'TP','1.5')
exec(@data)

But if you put them in each column, it would be easier

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -