t-sql 从带有变量名的字符串中获取变量值 [英] t-sql get variable value from string with variable name
本文介绍了t-sql 从带有变量名的字符串中获取变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法将@my_variable
字符串转换成@my_variable
的值?
Is there a way to convert @my_variable
string into a value of @my_variable
?
我有一个存储变量名称的表.我需要获取这个变量的值.像这样:
I have a table which stores names of variables. I need to get the value of this variable. Something like this:
DECLARE @second_variable AS NVARCHAR(20);
DECLARE @first_variable AS NVARCHAR(20);
SET @first_variable = '20';
SET @second_variable = SELECT '@first_variable'; --here I want that @second variable be assigned a value of "20".
推荐答案
解决您的问题最有可能的解决方案是解决/更改/修复设计,该设计要求为什么要有一个存储变量名称的表.
The most likely solution to your problem is to address/change/fix the design that requires why you would have a table that stores the names of variables.
这篇关于t-sql 从带有变量名的字符串中获取变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文