I know I need dynamic sql, but haven't gotten this to work:
I want to loop through a table and for each row, return the value of the field that is located by two columns for that row.
Tableabc Columnabc Tabledef Columndef Tablexyz Columnxyz
And I'm looking to return basically
Select [column] from [table] where column = 'desiredtext'
Where [column] and [table] are from the same row of another table, looping through all rows of the master table.
So, I'm basically searching hundreds of tables in my database for one specific textphrase, where the column and table names are not always the same, however they are readily identified by the query that results in the master table being created.
The goal being to search specific columns in the couple hundred tables that might have the
'desiredtext' I'm looking for, rather than search the entire database of thousands of tables.
What other info can I provide to help someone help me?