How do you find the number of rows in a table?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
select @@rowcount
select count(*) from tablename
Is This Answer Correct ? | 5 Yes | 7 No |
Do you know the cursor optimization tips?
What are the steps to follow to configure SQL*Net?
How can you stop stored procedures from recompiling?
How can i give the restrictions for the data entry, if i wish to enter only I ,II, III, IV in the grade actegory of student table?
What is subquery? Explain the properties of a subquery?
What is key attribute?
When is update_statistics command used?
Difference between LEN() and DATALENGTH() in sql server ?
How to Get the last identity value used
How to loop through result set objects using odbc_fetch_row()?
hi. suppose one person goal is strong knowledge on SQL.... suggest me ...if he learns SQL SERVER or ORACLE? which is best?
7 Answers Google, TCS, Unisys,
what is for foreign key ??
4 Answers CarrizalSoft Technologies, Sabic,