Showing posts with label textfile. Show all posts
Showing posts with label textfile. Show all posts

Sunday, February 19, 2012

how to know how many records in each table and output to textfile?

Hi,
Is there a fast way to know how many records in every tables?
Thanks a lot!
regards,
florencelee
This is an approximate rowcount, depending on when SQL Server last updated
its statistics, but it's fast.
SELECT OBJECT_NAME(id), rowcnt FROM sysindexes WHERE indid IN (0, 1) ORDER
BY 1
On the output, you could just copy/paste in Query Analyzer, or set up a
command line task and redirect the output to a file e.g.
osql -E -d <dbname> -Q "SELECT ...." > TableRowCount.txt
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:e7YZ39o0EHA.4004@.tk2msftngp13.phx.gbl...
> Hi,
> Is there a fast way to know how many records in every tables?
> --
> Thanks a lot!
> regards,
> florencelee
>
|||florencelee,
Or if you want accurate info use this query:
exec sp_msforeachtable 'select ''?'' as tablename, count(*) as
[rowcount] from ?'
Note: if your tables are large this query will take significant amount
of time.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
Peter Yeoh wrote:
> This is an approximate rowcount, depending on when SQL Server last updated
> its statistics, but it's fast.
> SELECT OBJECT_NAME(id), rowcnt FROM sysindexes WHERE indid IN (0, 1) ORDER
> BY 1
> On the output, you could just copy/paste in Query Analyzer, or set up a
> command line task and redirect the output to a file e.g.
> osql -E -d <dbname> -Q "SELECT ...." > TableRowCount.txt
>

how to know how many records in each table and output to textfile?

Hi,
Is there a fast way to know how many records in every tables?
Thanks a lot!
regards,
florenceleeThis is an approximate rowcount, depending on when SQL Server last updated
its statistics, but it's fast.
SELECT OBJECT_NAME(id), rowcnt FROM sysindexes WHERE indid IN (0, 1) ORDER
BY 1
On the output, you could just copy/paste in Query Analyzer, or set up a
command line task and redirect the output to a file e.g.
osql -E -d <dbname> -Q "SELECT ...." > TableRowCount.txt
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:e7YZ39o0EHA.4004@.tk2msftngp13.phx.gbl...
> Hi,
> Is there a fast way to know how many records in every tables?
> --
> Thanks a lot!
> regards,
> florencelee
>|||florencelee,
Or if you want accurate info use this query:
exec sp_msforeachtable 'select ''?'' as tablename, count(*) as
[rowcount] from ?'
Note: if your tables are large this query will take significant amount
of time.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
Peter Yeoh wrote:
> This is an approximate rowcount, depending on when SQL Server last updated
> its statistics, but it's fast.
> SELECT OBJECT_NAME(id), rowcnt FROM sysindexes WHERE indid IN (0, 1) ORDER
> BY 1
> On the output, you could just copy/paste in Query Analyzer, or set up a
> command line task and redirect the output to a file e.g.
> osql -E -d <dbname> -Q "SELECT ...." > TableRowCount.txt
>

how to know how many records in each table and output to textfile?

Hi,
Is there a fast way to know how many records in every tables?
--
Thanks a lot!
regards,
florenceleeThis is an approximate rowcount, depending on when SQL Server last updated
its statistics, but it's fast.
SELECT OBJECT_NAME(id), rowcnt FROM sysindexes WHERE indid IN (0, 1) ORDER
BY 1
On the output, you could just copy/paste in Query Analyzer, or set up a
command line task and redirect the output to a file e.g.
osql -E -d <dbname> -Q "SELECT ...." > TableRowCount.txt
--
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free!
"Florencelee" <florencelee@.visualsolutions.com.my> wrote in message
news:e7YZ39o0EHA.4004@.tk2msftngp13.phx.gbl...
> Hi,
> Is there a fast way to know how many records in every tables?
> --
> Thanks a lot!
> regards,
> florencelee
>|||florencelee,
Or if you want accurate info use this query:
exec sp_msforeachtable 'select ''?'' as tablename, count(*) as
[rowcount] from ?'
Note: if your tables are large this query will take significant amount
of time.
--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
Peter Yeoh wrote:
> This is an approximate rowcount, depending on when SQL Server last updated
> its statistics, but it's fast.
> SELECT OBJECT_NAME(id), rowcnt FROM sysindexes WHERE indid IN (0, 1) ORDER
> BY 1
> On the output, you could just copy/paste in Query Analyzer, or set up a
> command line task and redirect the output to a file e.g.
> osql -E -d <dbname> -Q "SELECT ...." > TableRowCount.txt
>