I have access to MS SQL Server with MS Access through ODBC, and I want to display the table names, their column names and the number of rows in the table. Table names are stored in a table named "sys_tables", column names in "sys_columns". Unfortunately, the number of rows in the table must be taken into account. Since I am not testing SQL, my first attempt does not work:
SELECT t.name, c.name, t.object_id, x.cnt
FROM sys_tables AS t INNER JOIN sys_columns AS c ON t.object_id = c.object_id
LEFT OUTER JOIN (SELECT COUNT(*) AS cnt FROM @t.name AS tbl ON tbl.cnt > 0) AS x
What is the correct way to use a computed string in a SELECT table name? Can I make a sub select that selects all rows without a real relationship?
source
share