use OUTPUT clause
DECLARE @INSERTED_IDS
(
PKCol int
)
INSERT INTO TableB
OUTPUT INSERTED.PKCol INTO @INSERTED_IDS
SELECT columns
FROM TableA
DELETE a
FROM TableA a
INNER JOIN @INSERTED_IDS i
ON i.PKCol=a.PKCol
Here PKCol is the primary key column of tableA (i'm assuming its f type integer else change datatype in table variable)