For any one table, you can get the number of rows with the following query:
| SELECT COUNT(*) FROM <tablename> |
To iterate through each table, though, you have to do a little more monkeying around (thanks to Dirk Goldar for the script):
SELECT Table_Name = Name, Row_Count = DCount("*",[MSysObjects].[Name]) FROM MSysObjects WHERE (Left([Name],1)<>"~") AND (Left([Name],4) <> "MSys") AND ([Type] In (1, 4, 6)) ORDER BY Name |
If you want to do this in ASP, you could call this query directly. Another approach would be to use ADOX to iterate through the list of tables, and execute SELECT COUNT(*) against each one:
<% dbname = "databasename" ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" ConnStr = ConnStr & "<path>\" & dbname & ".mdb" Set adox = CreateObject("ADOX.Catalog") Set conn = CreateObject("ADODB.Connection") conn.open ConnStr adox.activeConnection = conn for each table in adox.tables if table.type="TABLE" then response.write table.name & " - " set rs = conn.execute("SELECT COUNT(*) FROM " & table.name) response.write rs(0) & "<p>" end if next conn.close set conn = nothing set adox = nothing %> |