Record count in Audit Table

Who is online?  0 guests and 0 members
Home  »  Forums   »  microsoft business intelligence   »  sql server   » Record count in Audit Table

Record count in Audit Table

Topic RSS Feed

Posts under the topic: Record count in Audit Table

Posted: 12/2/2011

Jedi Youngling 74  points  Jedi Youngling
  • Joined on: 11/28/2011
  • Posts: 27

Hello All,

I have been assigned a task. I have simple stored procedure that inserts the records from one table into another everyday.This is my stored procedure

USE

[ESG]

GO

/****** Object: StoredProcedure [dbo].[usp_Auto_Load_ESG] Script Date: 12/02/2011 07:30:17 ******/

SET

ANSI_NULLS  

 

QUOTED_IDENTIFIER  

 

PROCEDURE [dbo].[usp_Auto_Load_ESG]

AS

TRUNCATE

TABLE dbo.Test 

INSERT

INTO dbo.test

SELECT

Customer_Tkn+'-'+Customer_Acct_Tkn+'-'+Account_Pkg_Tkn , Account_Pkg_Tkn

 ,Start_Date

 ,End_Date

 ,LDC_Account_Num

 ,FILE_NAME

 ,File_Date

FROM

dbo.test_raw

 

I need to create a log table for this. I have created a log table called test_audit that has columns

Audit_key

No.of records

File name

Date started

I wanted to populate my audit table as soon as my test table has the records. No. of records column in test_audit table should hold the no. of records got inserted into test table. Could anyone tell me how to get the no. of records?..For example today if 5000 records got inserted into test table then in my audit table no.of records column should show 5000...tomorrow if 6000 records got inserted into test table my audit table no.of records column should show 6000...Please suggest me where to add this audit table in my stored procedure and how to get the no.of records column in my audit table...

Any help is much appreciated.

Thanks so much 

 

 

 , Customer_Acct_Tkn


Posted: 12/2/2011

Padawan 1392  points  Padawan
  • Joined on: 1/3/2010
  • Posts: 250
Answered  Answered

sqlkala, use @@RowCount to return the number of rows affectd by last statement.

take a look http://technet.microsoft.com/en-us/library/ms187316.aspx


Page 1 of 1 (2 items)