How do you find the number of rows in a table?

Answers were Sorted based on User's Feedback



How do you find the number of rows in a table?..

Answer / hokar

select count(*) from tablename.

Is This Answer Correct ?    27 Yes 2 No

How do you find the number of rows in a table?..

Answer / uma lakshman

Hokar, You are right. But using count(*) is not optimal.

I wud suggest going for sysindexes table to find the number
of rows in a particular table.

SELECT rows FROM sysindexes WHERE id = OBJECT_ID
('table_name')

Is This Answer Correct ?    12 Yes 3 No

How do you find the number of rows in a table?..

Answer / kumar.t

Select Rows From SysIndexes Where Id = Object_Id
('tablename') And IndId<2

Uma Lakshman answer is wrong.

It Is Correct Answer

By
Kumar.T

Is This Answer Correct ?    12 Yes 3 No

How do you find the number of rows in a table?..

Answer / raghuram

the question is how do find number of rows in a table?

select count(*) from table_name

by using this we will get exact number of rows in a table.

Is This Answer Correct ?    10 Yes 1 No

How do you find the number of rows in a table?..

Answer / anand

select count(*) from table_name will hold good if there isn't any WHERE clause in it as it is a AGGREGATE Function.. (just additional information)

Is This Answer Correct ?    1 Yes 0 No

How do you find the number of rows in a table?..

Answer / manoj savalia

Try This

SELECT SYS_OBJ.NAME AS "TABLE NAME"
, SYS_INDX.ROWCNT AS "ROW COUNT"
FROM SYSOBJECTS SYS_OBJ, SYSINDEXES SYS_INDX
WHERE SYS_INDX.ID = SYS_OBJ.ID
AND INDID IN(0,1)
AND XTYPE = 'U'
AND SYS_OBJ.NAME <> 'SYSDIAGRAMS'
AND SYS_INDX.ROWCNT>0
ORDER BY SYS_INDX.rowcnt DESC

Is This Answer Correct ?    0 Yes 0 No

How do you find the number of rows in a table?..

Answer / elumalai.k

select @@rowcount
select count(*) from tablename

Is This Answer Correct ?    5 Yes 7 No

Post New Answer

More SQL Server Interview Questions

What is the language structure to add a record to a table?

0 Answers  


How we create SQL Server 2005 Reporting Services ? Give me Sample

0 Answers   HCL,


If we delete pack Spec what will be the status of pack Body ?

0 Answers   Nagarro,


how will u create "n" possible tables in sql...

1 Answers   Oracle,


What are the types of database schema? : sql server analysis services, ssas

0 Answers  






What are actions, how many types of actions are there, explain with example? : sql server analysis services, ssas

0 Answers  


Please tell me some knowledge about Clustering and how to add clustering?

1 Answers  


DIFFERENCE BETWEEN SQL SERVER 2005 and 2008

2 Answers   ADP,


Can group functions be mixed with non-group selection fields in ms sql server?

0 Answers  


Explain the microsoft sql server delete command? : SQL Server Architecture

0 Answers  


What do you understand by triggers and mention the different types of it?

0 Answers  


What is the name of the system variable that returns the number of rows affected by a SQL statement?

0 Answers   HCL,


Categories