Posted: 12/2/2011
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
,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
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