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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping Through All Table Names in a DB

Status
Not open for further replies.

SQLJoe

Technical User
Dec 8, 2010
43
US
I need to automatically load the contents of a number of tables into a single table. I'd like to set up a loop that iterates through a list of all the table names, tests each name to see if it follows a certain naming convention, and if it does, append the contents into another table. I can do all this if I can just get a list of all the tables loaded into an array or recordset. How can I do this?
 
open this recordset
Code:
SELECT MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE (((MSysObjects.Type) In (1,4)));
'1=table 4= linked table
 
I'd add 6:
SELECT Name FROM MSysObjects WHERE Type In (1,4,6)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This is good information, but I'm running this in a project, so I can't run a query like this because it tries to run it against sql server. What would be the code equivalent? Thanks!
 

Oops, please isregard my former comment. With all your help, I got it now. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top