SQL Server数学表达式

编程入门 行业动态 更新时间:2024-10-18 03:23:23
本文介绍了SQL Server数学表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我会得到一个如下字符串,它将是一个数学表达式 1)5 + 5 * + Min(5,5,9) =? 2)Max(5 + 5,5 + 9,8-3)+ 6 =? 3)Max((5 + 5),(5) +9),(8-3))* 9 =? 4)(最大(最小(5,5),最大(5,9),最小(3,9))* 8 )+ 23 =? i将在sql server中获取它,因为string.I需要通过sql server获取字符串的输出 。这个字符串纯动态。 如果有任何解决方案,请帮助我。 谢谢 Ayan

Hi , I will get a string like below , it will be a mathematical expression 1)5+5*+Min(5,5,9)=? 2)Max(5+5,5+9,8-3)+6=? 3)Max((5+5),(5+9),(8-3))*9=? 4)(Max(Min(5,5),Max(5,9),Min(3,9))*8)+23=? i will get it in sql server , as string.I need to get the output of the string by sql server.This string purely dynamic. Please help me , if any solution is available. Thanks Ayan

推荐答案

考虑到这一点,我认为这是一个糟糕的想法... In SQL你可以执行动态查询,所以你可以做这样的事情 With the consideration, that this looks me as an awful idea... In SQL you can execute dynamic queries, so you can do something like this DECLARE @SQL VARCHAR(MAX) = 'SELECT (5+5)' EXEC(@SQL)

您需要注意的一点是表达式的有效格式 - 在您的示例中并非所有表达式都是有效的SQL ...

One point you have to take care of is the valid format of the expressions - in your samples not all expressions are valid SQL...

更多推荐

SQL Server数学表达式

本文发布于:2023-11-10 16:17:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575863.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表达式   数学   SQL   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!