Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / March 2008

Tip: Looking for answers? Try searching our database.

Total # of records.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lost Soul - 12 Mar 2008 00:29 GMT
Ok, this is dumb. How do I get the total number of records in an SQL table.

I know I've done this before, but the mind is mush.

Thanks.
Dan Guzman - 12 Mar 2008 00:38 GMT
> Ok, this is dumb. How do I get the total number of records in an SQL
> table.

Use a COUNT aggregate:

SELECT COUNT(*) FROM dbo.MyTable;

You also have the option in SQL 2005 to get an approximate count using the
catalog views (e.g. sys.partitions).  This can be much faster than counting
the individual rows.

Signature

Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

> Ok, this is dumb. How do I get the total number of records in an SQL
> table.
>
> I know I've done this before, but the mind is mush.
>
> Thanks.
Lost Soul - 12 Mar 2008 00:52 GMT
Thanks Dan, I got it, I must have posted just after you.

Cheers and thanks.
>> Ok, this is dumb. How do I get the total number of records in an SQL
>> table.
[quoted text clipped - 13 lines]
>>
>> Thanks.
Lost Soul - 12 Mar 2008 00:47 GMT
Never mind all, I figured it out - stupid me.

SELECT count(COLUMN) FROM dbo.TABLEname

Sorry folks.

> Ok, this is dumb. How do I get the total number of records in an SQL
> table.
>
> I know I've done this before, but the mind is mush.
>
> Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.