gpt4 book ai didi

tsql - 如何测试 tsql 变量内容作为表达式

转载 作者:行者123 更新时间:2023-12-05 01:20:58 31 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to execute mathematical expression stored in a varchar variable

使用纯 TSQL,是否可以计算定义为变量的表达式?

这是一个简单的例子,仅用于概念验证:

DECLARE @TestValue AS VARCHAR (2) = '7';
DECLARE @myRule AS VARCHAR (100) = 'case when (#val#>0 and #val#<10) then 1 else 0 end';

SET @myRule = replace(@myRule, '#val#', @TestValue);
PRINT @myRule;
-- case when (7>0 and 7<10) then 1 else 0 end

--How to evaluate the expression in @myRule for True/False?

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com