I load the data into a table as follows:
DECLARE @srcRc INT;
DECLARE @dstRc INT;
SET @srcRc = ( SELECT COUNT(*) FROM A )
INSERT INTO t
(Col1
,Col2
,Col3
)
SELECT A.Col1
,A.Col2
,B.Col3
FROM A
JOIN B
ON A.Id = B.Id;
SET @dstRc = @@ROWCOUNT
Now I am comparing the variables @srcRcand @dstRc. The value ROWCOUNTmust be the same. If this is not the case, the inserted rows must be deleted.
Q1: What would be the best strategy to roll back inserted rows?
I have a couple of ideas:
1) , .
2) () toBeDeleted, , toBeDeleted 1, . (while-loop).
, t.
3) , . , .
DECLARE @srcRc INT;
DECLARE @dstRc INT;
SET @srcRc = ( SELECT COUNT(1) FROM A );
SET @dstRc = ( SELECT COUNT(1) FROM A JOIN B ON A.Id = B.Id );
Q2: , , 10-100 .?
Q3: ?