0

If I have number of tables in my database and I want to know the number of records that table is consisting. What I have done so far is:

 Select name as Product from sysobjects where xtype='U'
 order by name 

and I got the total tables. eg.

Product
--------
apple
nokia
sony
samsung
motorola

How to find the total number of records the table is containing?

nishant
  • 61
  • 1
  • 10

2 Answers2

1

got it.

Select distinct obj.name,i.rowcnt as product from sysobjects obj 
 inner join sysindexes i 
 on obj.id=i.id
 where  xtype='U' and rowcnt>0
 order by i.rowcnt desc
nishant
  • 61
  • 1
  • 10
0

use count() function to fetch total number of records

Select count(*) from tablename;

Vibha Thakur
  • 171
  • 1
  • 1
  • 10