|
Home > Archive > MS SQL Server > October 2006 > table query
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| coenzyme 2006-10-24, 6:37 pm |
| Does anyone have a query that will select a group of tables and at a
scheduled time return the number of records in each table to another table?
Thanks to eveyone for being there to help.
SQL 2000
| |
| Paul Ibison 2006-10-24, 6:37 pm |
| Create a logging table tTableSizes with 3 columns :
tablename,tablerowco
unt,timerecorded.
Insert into tTableSizes(tablerow
count,tablename,time
recorded)
Select count(*) as total, 'mytable1' as tablename, getdate() as daterecorded
from mytable1
Insert into tTableSizes(tablerow
count,tablename,time
recorded)
Select count(*) as total, 'mytable2' as tablename, getdate() as daterecorded
from mytable2
etc.
Schedule this in a job.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .
| |
| coenzyme 2006-10-24, 6:37 pm |
| Thanks soooo much Paul.
"Paul Ibison" wrote:
> Create a logging table tTableSizes with 3 columns :
> tablename,tablerowco
unt,timerecorded.
>
> Insert into tTableSizes(tablerow
count,tablename,time
recorded)
> Select count(*) as total, 'mytable1' as tablename, getdate() as daterecorded
> from mytable1
>
> Insert into tTableSizes(tablerow
count,tablename,time
recorded)
> Select count(*) as total, 'mytable2' as tablename, getdate() as daterecorded
> from mytable2
>
> etc.
>
> Schedule this in a job.
>
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com .
>
>
>
|
|
|
|
|