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.
Author |
Topic |
arunsqladmin
Yak Posting Veteran
74 Posts |
Posted - 2008-04-24 : 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
52326 Posts |
Posted - 2008-04-24 : 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
30421 Posts |
Posted - 2008-04-24 : 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 - 2008-04-24 : 04:09:14
|
i want to check number of records getting inserted in a database. |
 |
|
arunsqladmin
Yak Posting Veteran
74 Posts |
Posted - 2008-04-24 : 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
30421 Posts |
Posted - 2008-04-24 : 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
133 Posts |
Posted - 2008-05-27 : 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.ManojMCP, MCTS |
 |
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2008-05-27 : 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 ASset ANSI_NULLS ONset QUOTED_IDENTIFIER ON-- Declare local variablesEXEC master..sp_MSForeachdb 'USE IF DB_ID(''?'')>4BEGIN 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'GOTerry |
 |
|
|
|
|
|
|