Reputation: 33
We have a production server through access with about 130 tables, management wants to add a table that gives the count of all the rows in each table; IE table with the name of [53462] has 10678 rows. We have a table that contains the nice name and true name of all of the tables and they would like all the counted rows in another column of that same table.
My current solution which is a little taxing is to use an external program to write up a CSV file that goes through all the tables and runs a COUNT statement, obviously, this is a very slow process and often results in mistakes on number accounting due to the number of rows changing so often in the tables.
Our tables all have names like 02461, 02623 save for the Key table that has all of the names in it. The key table looks like the following, names changed for security,
|ID| Title |Part Number|
|24|Bob Jones |02461 |
|34|Jacob Statham |02623 |
etc.
Whereas the output they want, and our awkward solution shows, is:
|ID| Title |Part Number|Rows |
|24|Bob Jones |02461 |10000|
|34|Jacob Statham |02623 |15000|
In summary, what we are looking at is somehow joining a query of a given value to a row in a table.
Upvotes: 1
Views: 76
Reputation: 3031
SELECT ID, Title, [Part number], Dcount('*',[Part number]) As Rows FROM [Key]
Upvotes: 1