So im going through a schema here Ive never worked with before. There are no relationships between tables.
The initial table has the name of the other tables I need to continue getting info from.
So If I retrieve the table name from the initial table, how can I use that table name in the same stored procedure later on?
The initial table is AE_Table1. It has a number of columns. 2 of those contain the names of the tables I need for each entry. So
Select tb2Name
from AE_Table1
where ID = 1
Will give me the name of the first table I need. Then I need to store that value in a variable, table2Name for example, and use it later.
Select *
from @table2Name
Where xyz
So is there a way for me do do this? (please forgive any mistakes above, Im just writing this quickly to show what I need, its not meant to be 100% syntactically correct)
Thanks.