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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Calculations with Queries

Author  Topic 

PaulHamill
Starting Member

1 Post

Posted - 2003-04-24 : 08:07:14
All

I have written a Stored Procedure to Run on a daily basis to record the number of records in each of the tables within my database. The ouput of this script is to a table and is as follows...

Date TableName NoOfRecords
23-04-2003 TableA 10
23-04-2003 TableB 50
24-04-2003 TableA 15
24-04-2003 TableB 60

I want to be able to work out the daily increase in records of each of the tables. Does anyone have any ideas,

Thanking you all in advance

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-04-24 : 08:32:14
[url="http://www.sqlteam.com/item.asp?ItemID=3856"] Calculating Running Totals
[/url]

Jay White
{0}
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2003-04-24 : 08:32:49
http://www.sqlteam.com/item.asp?ItemID=3856

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-04-24 : 08:36:57
select t1.TableName, t1.Date, t1.NoOfRecords - t2.NoOfRecords
from tbl.t1, tbl.t2
where t1.TableName = t2.TableName
and t2.Date = (select min(t3.Date) from tbl t3 where t1.TableName = t3.TableName and t3.Date > t1.Date)
order by t1.TableName, t1.Date

also see
www.nigelrivett.com
Get number of rows in tables

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -