Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 sqlserver

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-09-19 : 07:43:19
priya writes "what is the best method to count the number of records in a table?"

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-19 : 07:53:09
select count(*) from MyTable (nolock)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-19 : 08:13:28
Or:

SELECT rows FROM sysindexes WHERE id = OBJECT_ID('table_name') AND indid < 2


Much faster, less reliable !

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page
   

- Advertisement -