DECLARE @cnt INT
SELECT @cnt = COUNT(*) FROM RateLevelRoomTypeXTab_Hist WITH (NOLOCK)
IF ISNULL(@cnt, 0) = 0
BEGIN
  INSERT INTO RateLevelRoomTypeXTab_Hist
  SELECT ID, FKRateLevelId, FKRoomTypeNumber, GETDATE()
  FROM RateLevelRoomTypeXTab
END

DECLARE @cnt1 INT
SELECT @cnt1 = COUNT(*) FROM RateLevelRoomTypeRestrictionXTab_Hist WITH (NOLOCK)
IF ISNULL(@cnt1, 0) = 0
BEGIN
  INSERT INTO RateLevelRoomTypeRestrictionXTab_Hist
  SELECT FKRateLevelRoomTypeXTabId, FKRateLevelRestrictionId, DateStamp, RestrictionLength, RoomsAllocated, RoomsAvailableRoomType, RoomsAvailableTotal, GETDATE()
  FROM RateLevelRoomTypeRestrictionXTab
END