Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select query built from previous select data 1

Status
Not open for further replies.

larrabee

Programmer
Jan 30, 2006
17
0
0
US
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
Code:
declare @test as varchar(20)
set @test = 'table2'
select * from  @test

thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top