Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Variable question

Author  Topic 

Detrender
Starting Member

1 Post

Posted - 2011-06-18 : 07:09:39
Does anyone know if it is possible to reference a variable with a variable? I have two variable @VAR1='Address' @VAR2=1 is there a way to use the value containted in @VAR2 to reference @VAR1. It would look something like @VAR(@VAR2) with the 1 in @VAR1 replaced with the variable in @VAR2. Confusing question, thanks in advance.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-18 : 08:10:47
That's not possible with T-SQL.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-06-20 : 12:25:39
You may need to use a dynamic sql. But why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -