I have an insert statement:
insert into parentTbl
select firstId, secondId, thirdId, dateTm
from importTbl
where codeId = @codeIdParam
I need to reliably find out if that insert inserted anything at all. Ideally, I would like to set a @insertedCount
variable to the number of rows inserted, even if that is 0.
I am currently using:
set @insertedCount = @@ROWCOUNT
But that only seems to get the last number of inserted rows - the problem is that if the INSERT SELECT
statement did not insert anything the @@ROWCOUNT
does not return 0.