All Forums Tools
hsyed44 9 posts Joined 01/10
6 weeks ago
How to Capature number of rows inserted using stored procedure

I would like to capture the number of rows inserted. I need to do this all in a stored procedure. Here is my sql for inserting the rows,

Insert into DEV_CORE.TABLE1
(SurrogateKey, COL1, COL2...)

Select

SURROGATEKEY
,COL1
,COL2


From
DEV_STG.TABLE1


WHERE NOT EXISTS
( SELECT 1
FROM
DEV_CORE.TABLE1 as CORE1
WHERE CORE1.COL1= STG.COL2
AND CORE1.COL2= STG.COL2
)

So once the records are inserted i need to find out how many were inserted. I m thinking count* or some how use row_number ?? Please help. Thanks.

dnoeth 684 posts Joined 11/04
5 weeks ago

Within a SP there's a built-in variable ACTIVITY_COUNT which is set to that number after each execution of a DML statement.

Dieter

You must sign in to leave a comment.