--nb20120614 Ensure the change from old to new table booking is not coliding
declare @OldId INT, @NewId INT, @Id INT
select @OldId = MAX(RestaurantReservationNumber) from RestaurantReservations with (nolock) 
select @NewId = MAX(ReservationConfLineNumber) from RESERVATIONCONFERENCELINE with (nolock) 
select @Id = IdentityField from IdentityFields with (nolock) where DbTableName = 'RESERVATIONROOMLINEIDENTITY'
if @Id < @OldId or  @NewId > @Id
begin
  if @NewId > @Id
    SET @Id = @NewId
  else
    SET @Id = @OldId
  update IdentityFields SET IdentityField = @Id where DbTableName = 'RESERVATIONROOMLINEIDENTITY'
  if @@ROWCOUNT = 0
    RAISERROR('RESERVATIONROOMLINEIDENTITY NEED TO BE UPDATED MANUALLY. NO RECORD FOUND!',15,1)
  
end
