Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to get given databse all tables name with number of records count.
Posted

 
Share this answer
 
Comments
Prosan 5-Jun-12 2:37am    
please write here a query.
Prasad_Kulkarni 5-Jun-12 4:42am    
You can get complete details on both links, the first one provides query with results which is more useful to you rather than adding query here, this is what I thought.
SQL
use yourDatabaseName
go
SELECT
T.TABLE_NAME AS [TABLE NAME], MAX(I.ROWS) AS [RECORD COUNT]
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
order by [RECORD COUNT] desc
 
Share this answer
 
Comments
Prosan 5-Jun-12 3:43am    
good answer
member60 29-Jun-12 5:08am    
my 5!
SQL
USE YOURDBNAME
GO
SELECT *
FROM sys.Tables
 
Share this answer
 
Comments
Prosan 5-Jun-12 2:38am    
this query return only name of tables but i want no. of records also

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900