| Author |
Topic  |
|
|
arunsqladmin
Yak Posting Veteran
74 Posts |
Posted - 04/24/2008 : 02:31:47
|
| i want to check how many records are getting inserted into my database per day..can some one help in creating a trigger which gives the count |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47023 Posts |
Posted - 04/24/2008 : 02:40:06
|
| DO you want the count of records inserted to all tables in your db for a day or you just want count inserted to particular table? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 04/24/2008 : 02:49:26
|
This depends on your design.
If you have a DATETIME column which keep track of insert date and time, this is easy. If you do not have a DATETIME column, you will need an auxiliary table to keep track of number of records to yesterday and then compare todays count with last recorded count in the auxiliary table.
E 12°55'05.25" N 56°04'39.16" |
 |
|
|
arunsqladmin
Yak Posting Veteran
74 Posts |
Posted - 04/24/2008 : 04:09:14
|
| i want to check number of records getting inserted in a database. |
 |
|
|
arunsqladmin
Yak Posting Veteran
74 Posts |
Posted - 04/24/2008 : 04:11:06
|
| is there any way where i can construct a trigger to count the number of records getting inserted per day in a database |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 04/24/2008 : 04:12:31
|
Yes, we understand that. Did you read my previous reply? Do you have any comments on that?
E 12°55'05.25" N 56°04'39.16" |
 |
|
|
mdubey
Posting Yak Master
USA
133 Posts |
Posted - 05/27/2008 : 10:50:42
|
If this is for one time then please go with Peso, or else if you need for long term to monitor this actions, I would suggest you to create a report in SQL Reporting services. So would come to know how many inserted/Delted/updated.
Manoj MCP, MCTS |
 |
|
|
tosscrosby
Aged Yak Warrior
USA
676 Posts |
Posted - 05/27/2008 : 15:17:58
|
I use the following, although I only have it scheduled to run weekly. It allows me to project, over time, how much my data is growing and what my disk needs will be. It inserts into a table with a date run stamp and does NOT include system databases. HTH.
CREATE PROCEDURE usp_DataRowCounts AS
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON -- Declare local variables EXEC master..sp_MSForeachdb ' USE IF DB_ID(''?'')>4 BEGIN
insert into DBMaint..DataRowCounts SELECT o.name, i.rowcnt, getdate() as RunDate, ''?'' FROM sysobjects o, sysindexes i WHERE i.id = o.id AND indid IN(0,1) AND xtype = ''u''
END'
GO
Terry |
Edited by - tosscrosby on 05/27/2008 15:18:56 |
 |
|
| |
Topic  |
|