USE YOURDBNAME
SELECT COUNT(*) from information_schema.tables
WHERE table_type = 'base table'
' Will return you the count of the tables in the database
Did you like this post?
|
|
|
||
|
|
|
|
|
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |




comments
16 Responses to "Count number of tables in a SQL Server database"This SQL Server 2005 is Easy to use
more feature include in microsoft.
Nice Tip!! :-D
It's works fine!
Thanks!
Thanks for the query. Its not working for sample databases such as AdventureWorks db.
Error: Invalid object name 'information_schema.tables'.
Prawin:
It works.
USE AdventureWorks
SELECT COUNT(*) from information_schema.tables
WHERE table_type = 'base table'
Thanks a lot!
Thank you,
it works & the sql is not complicated :-)
Gracias por el query, funciona bien :) pero deberias especificar que solo cambien el nombre de la BD y nada mas el resto no se toca.
USE NombredelaBasedeDatos
SELECT COUNT(*) from information_schema.tables
WHERE table_type = 'base table'
Alternative Query is
SELECT count(*) from sys.tables where type_desc = 'USER_TABLE'
Thanks...the information proved useful!
thank you for the useful information !
thanku
select 'Owner'=convert(char(10),t.TABLE_SCHEMA),
'Table Name'=convert(char(25),t.TABLE_NAME),
'Record Count'=max(i.rows)
from sysindexes i, INFORMATION_SCHEMA.TABLES t
where t.TABLE_NAME = object_name(i.id)
and t.TABLE_TYPE = 'BASE TABLE'
group by t.TABLE_SCHEMA, t.TABLE_NAME
Thanks much - very helpful
thats gr8 !
I hav multiple schema in DB.
How can i identify that result given is for that particular schema n not cumulative?
thanx a lot
Post a Comment