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,COL2From 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.
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
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.