Saturday, February 25, 2012

DB Metric?

I would like to do a query that would list all of the user tables and
give me counts for columns and rows. Someone probably has already made
that query. Thanks!
-JohnThe undocumented sp_MSforeachtable stored procedure can be used to execute
most any command against each table in a database.
http://www.dbazine.com/sql/sql-articles/larsen5
For example:
EXEC sp_MSforeachtable 'SELECT ''?'', COUNT(*) FROM ?'
"John Baima" <john@.nospam.com> wrote in message
news:rajdq1hqdh7j39emuei3gnhqsa4pt1b352@.
4ax.com...
>I would like to do a query that would list all of the user tables and
> give me counts for columns and rows. Someone probably has already made
> that query. Thanks!
> -John|||See if this helps:
http://groups.google.com/group/micr...2e?dmode=source
Anith|||"JT" <someone@.microsoft.com> wrote:

>The undocumented sp_MSforeachtable stored procedure can be used to execute
>most any command against each table in a database.
>http://www.dbazine.com/sql/sql-articles/larsen5
>For example:
>EXEC sp_MSforeachtable 'SELECT ''?'', COUNT(*) FROM ?'
>
That's interesting. How about the number of columns?
-John|||On Tue, 20 Dec 2005 11:10:46 GMT, John Baima wrote:

>"JT" <someone@.microsoft.com> wrote:
>
>That's interesting. How about the number of columns?
>-John
Hi John,
SELECT TABLE_NAME, COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
GROUP BY TABLE_NAME
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

No comments:

Post a Comment