As mentioned in the comments, you should always try to avoid loops in SQL code. But in this case, something like this should work:
WHILE Exists(SELECT 1 FROM @table2)
BEGIN
DECLARE @Id int;
SELECT TOP 1 @Id = Id FROM @table2 ORDER BY Id;
EXEC ups_doSth @Id;
DELETE FROM @table2 WHERE Id = @Id;
END;