|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Evaluate() or similar function in sql server 2000 or sql server 2005 ?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 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 > > > > > 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 >> >> >> >> >> > > "Luqman" <pearls***@cyber.net.pk> wrote in message Nice touch :)news:OA8HfahyGHA.4976@TK2MSFTNGP04.phx.gbl... > No Dear, >> 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 programmingpractice. 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. 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 > > > > > > >
a question for the soldiers on the line
Need advice on Backup Explicit insert for Timestamp column in Insert Trigger nText,Text,Image field problem for Update/Delete Trigger rename SELECT * Storing URLs in Sql Server - Beginner - Bad to use ANSI_PADDING OFF? Merging two tables Why does this query work but that one does not Update for table without Primary key Trigger expression always evaluates to true |
|||||||||||||||||||||||