t-sql get variable value from string with variable name
Posted
by Markus
on Stack Overflow
See other posts from Stack Overflow
or by Markus
Published on 2010-03-02T13:35:17Z
Indexed on
2010/05/17
3:00 UTC
Read the original article
Hit count: 244
tsql
Hi. 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".
© Stack Overflow or respective owner