none
Reading Math Expressions in SQL

    Question

  • Hello All,

    I need help regarding reading complex math expressions in SQL and evaluating them.

    For instance, (a+b)/c is a simple math expression which has been stored in table.

    Now I want to know how SQL understands this expression and evaluates accordingly.

    P.S. The above expression is being stored from .net application to SQL database.

    Please advise.

    Thanks!

    Friday, November 18, 2011 7:15 PM

Answers

  • Now I want to know how SQL understands this expression and evaluates accordingly.

     


    No SQL does not understand. Only Artificial Intelligence (and human) understands.

    You can pass math expressions to T-SQL for evaluation using dynamic SQL:

    http://www.sqlusa.com/bestpractices/dynamicsql/

     


    Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM
    Friday, November 18, 2011 8:00 PM
    Moderator
  • SQL is a data language; it is not meant to write parsers and compilers. Pass the string to such a program.
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL
    Saturday, November 19, 2011 12:56 AM

All replies

  • Now I want to know how SQL understands this expression and evaluates accordingly.

     


    No SQL does not understand. Only Artificial Intelligence (and human) understands.

    You can pass math expressions to T-SQL for evaluation using dynamic SQL:

    http://www.sqlusa.com/bestpractices/dynamicsql/

     


    Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM
    Friday, November 18, 2011 8:00 PM
    Moderator
  • SQL is a data language; it is not meant to write parsers and compilers. Pass the string to such a program.
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL
    Saturday, November 19, 2011 12:56 AM