Saturday, February 25, 2012

Records in a database

I need some help. How can I find how many records are in a data base.
In a table, or database?
In a table.. Select count(*) from tableName.
"robert_at_cbb" <robertatcbb@.discussions.microsoft.com> wrote in message
news:5DA210D7-62ED-4209-A7AB-8A3D828B228F@.microsoft.com...
>I need some help. How can I find how many records are in a data base.
|||For a quick (estimated ) rowcount, sp_spaceused tablename,,, This data is
stored in Sysindexes, in case you wish to write your own query.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"robert_at_cbb" <robertatcbb@.discussions.microsoft.com> wrote in message
news:5DA210D7-62ED-4209-A7AB-8A3D828B228F@.microsoft.com...
> I need some help. How can I find how many records are in a data base.
|||Thanks guys, how would I colloct the record count of the database.
"Wayne Snyder" wrote:

> For a quick (estimated ) rowcount, sp_spaceused tablename,,, This data is
> stored in Sysindexes, in case you wish to write your own query.
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "robert_at_cbb" <robertatcbb@.discussions.microsoft.com> wrote in message
> news:5DA210D7-62ED-4209-A7AB-8A3D828B228F@.microsoft.com...
>
>
|||Expanding on Wayne's response, you can get an estimated rowcount from
sysindexes using the query below. You can execute sp_spaceused
@.updateusage=true beforehand to improve accuracy.
SELECT SUM(rows)
FROM sysindexes
WHERE
indid IN(0, 1) AND
OBJECTPROPERTY(id, 'IsMSShipped') = 0
Hope this helps.
Dan Guzman
SQL Server MVP
"robert_at_cbb" <robertatcbb@.discussions.microsoft.com> wrote in message
news:55495ECE-2FC4-4C9C-BDBA-EE76A73E6639@.microsoft.com...[vbcol=seagreen]
> Thanks guys, how would I colloct the record count of the database.
> "Wayne Snyder" wrote:
|||robert_at_cbb wrote:[vbcol=seagreen]
> Thanks guys, how would I colloct the record count of the database.
> "Wayne Snyder" wrote:
There was a recent post on this same problem:
See the thread called "Total rows in Database". There were a number of
solutions presented.
David Gugick
Imceda Software
www.imceda.com

No comments:

Post a Comment