SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 check how many records are getting inserted
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

arunsqladmin
Yak Posting Veteran

74 Posts

Posted - 04/24/2008 :  02:31:47  Show Profile  Reply with Quote
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
52309 Posts

Posted - 04/24/2008 :  02:40:06  Show Profile  Reply with Quote
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?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30111 Posts

Posted - 04/24/2008 :  02:49:26  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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"
Go to Top of Page

arunsqladmin
Yak Posting Veteran

74 Posts

Posted - 04/24/2008 :  04:09:14  Show Profile  Reply with Quote
i want to check number of records getting inserted in a database.
Go to Top of Page

arunsqladmin
Yak Posting Veteran

74 Posts

Posted - 04/24/2008 :  04:11:06  Show Profile  Reply with Quote
is there any way where i can construct a trigger to count the number of records getting inserted per day in a database
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30111 Posts

Posted - 04/24/2008 :  04:12:31  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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"
Go to Top of Page

mdubey
Posting Yak Master

USA
133 Posts

Posted - 05/27/2008 :  10:50:42  Show Profile  Reply with Quote
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
Go to Top of Page

tosscrosby
Aged Yak Warrior

USA
676 Posts

Posted - 05/27/2008 :  15:17:58  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000