I am wondering if it is possible, and someone could point me in the right direction.
I would like to pull data from one table, which will reference what table and field I need from another table.
For Example
Table1
ID - int
tbl2 - varchar(50)
fld1 - varchar(50)
table2
ID
data - varchar(80)
I want to do a select statement on table, return 1 row, and use that row's data to know what i need to select and from what table.
if this isnt clear, please let me know.
I tried something similar to this, and simply get an error that I must declare the variable that i am all ready declaring
thanks for your help.
I would like to pull data from one table, which will reference what table and field I need from another table.
For Example
Table1
ID - int
tbl2 - varchar(50)
fld1 - varchar(50)
table2
ID
data - varchar(80)
I want to do a select statement on table, return 1 row, and use that row's data to know what i need to select and from what table.
if this isnt clear, please let me know.
I tried something similar to this, and simply get an error that I must declare the variable that i am all ready declaring
Code:
declare @test as varchar(20)
set @test = 'table2'
select * from @test
thanks for your help.