could be something like this?
DECLARE @time1 as datetime;
SELECT TOP 1 @time1 = time FROM table1 ORDER BY ID DESC;
IF ((SELECT COUNT(*) FROM table2 WHERE time = @time1) = 0)
BEGIN
INSERT INTO table2 VALUES (@time1);
END
ELSE
BEGIN
UPDATE table2 SET time = time1 WHERE time = @time1;
END
supousing ID is the pk of table1 and is identity that help us to know the last record