(kr*****@hotmail.co.uk) writes:
The database is a back end DB to a Microsoft system (SMS). There are a
number of collection tables that perform different tasks against there
contents. Listed in the DB are unique objects that are linked by a
primary key across the tables. These unique objects can exist in any
number of the tables depending on what task is required.
What I was hoping to get is a list of tables (tasks) that a unique
object is listed in, and the list of tables I want to search in (which
change daily) are found in tblA.
Hope this makes things clearer.
Can it be done in a single query?
No. A query always exactly define set of tables and columns. If you don't
know which tables that you want to access, you will need to build the
query dynamically along the pattern in my first post. You could build
that query in T-SQL or in a client language, whatever your preference.
But once you know which table to query, you can query all at once if you
like. (Running a loop and querying one table at a time is not likely to
have much extra cost.)
--
Erland Sommarskog, SQL Server MVP,
es****@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx