Home All Groups Group Topic Archive Search About

Evaluate() or similar function in sql server 2000 or sql server 2005 ?

Author
27 Aug 2006 7:18 PM
Luqman
I have a field where different formulas are saved in a varchar field.

for example:

143*23*33
Qty*Rate/100
Qty*Amount/100

Is there any function in Sql Server 2000 or Sql Server 2005 which can
calculate this string.

Best Regards,

Luqman

Author
27 Aug 2006 7:36 PM
Steve Dassin
You mean this:
http://www.alphora.com/docs/O-System.Evaluate.html

:)

http://racster.blogspot.com/

Show quoteHide quote
"Luqman" <pearls***@cyber.net.pk> wrote in message
news:%23Rbuk2gyGHA.1936@TK2MSFTNGP04.phx.gbl...
>I have a field where different formulas are saved in a varchar field.
>
> for example:
>
> 143*23*33
> Qty*Rate/100
> Qty*Amount/100
>
> Is there any function in Sql Server 2000 or Sql Server 2005 which can
> calculate this string.
>
> Best Regards,
>
> Luqman
>
>
>
>
>
Are all your drivers up to date? click for free checkup

Author
27 Aug 2006 8:22 PM
Luqman
No Dear, I was looking for the following which solved my problem.

'Example No. 1

execute ('select ' + '2+2*2')


'Example No. 2
DECLARE @proc_name varchar(30)
SET @proc_name = 'select 2+2*2'
execute (@proc_name)


'Example No. 3
Declare @mvalue varchar(30)
SET @mvalue='2+2*2'
Set @mvalue = 'select ' + @mvalue
execute (@mvalue)

Best Regards,

Luqman





Show quoteHide quote
"Steve Dassin" <steve@nospamrac4sql.net> wrote in message
news:OKCFHBhyGHA.3844@TK2MSFTNGP06.phx.gbl...
> You mean this:
> http://www.alphora.com/docs/O-System.Evaluate.html
>
> :)
>
> http://racster.blogspot.com/
>
> "Luqman" <pearls***@cyber.net.pk> wrote in message
> news:%23Rbuk2gyGHA.1936@TK2MSFTNGP04.phx.gbl...
>>I have a field where different formulas are saved in a varchar field.
>>
>> for example:
>>
>> 143*23*33
>> Qty*Rate/100
>> Qty*Amount/100
>>
>> Is there any function in Sql Server 2000 or Sql Server 2005 which can
>> calculate this string.
>>
>> Best Regards,
>>
>> Luqman
>>
>>
>>
>>
>>
>
>
Author
27 Aug 2006 9:17 PM
Steve Dassin
"Luqman" <pearls***@cyber.net.pk> wrote in message
news:OA8HfahyGHA.4976@TK2MSFTNGP04.phx.gbl...
> No Dear,

Nice touch :)
Author
27 Aug 2006 9:58 PM
--CELKO--
>> I have a field [sic] where different formulas are saved in a varchar field [sic]. <<

1) You can use dynamic SQL, which is considered a poor programming
practice.  Surely you do not have an application where any user can
throw in a formula on the fly.

2) You can use a spreadssheet or other tool which is meant for
computations.  SQL is meant for data storage and retrieval.

3) You can hide the formulas in a VIEW.
Author
28 Aug 2006 4:54 AM
Steve Kass
Luqman,

Here's another approach that works for a similar problem::

http://www.users.drew.edu/skass/sql/Infix.sql.txt

Steve Kass
Drew University
www.stevekass.com

Luqman wrote:

Show quoteHide quote
>I have a field where different formulas are saved in a varchar field.
>
>for example:
>
>143*23*33
>Qty*Rate/100
>Qty*Amount/100
>
>Is there any function in Sql Server 2000 or Sql Server 2005 which can
>calculate this string.
>
>Best Regards,
>
>Luqman
>
>
>
>
>

>

Bookmark and Share

Post Thread options