--DECLARE @NumberOfBeds INT
DECLARE @NumberOfBeds VARCHAR(50)
DECLARE @JournalNumber VARCHAR(50)
DECLARE @HotelNumber INT
DECLARE @HotelCustomerNumber INT

DECLARE @HotelSetupNumber INT
DECLARE @HotelSetupValueNumber INT
DECLARE @Identity INT

DECLARE @CentralBookingType INT
SELECT @CentralBookingType = Convert(Integer,isnull(KeyValue,0)) from HotelSetup WITH (Nolock) where searchkey = 'CentralBookingType'

IF ISNULL(@CentralBookingType, 0) > 0
BEGIN
  DECLARE dbcur CURSOR FOR
    SELECT FlagA, FlagB, HotelNumber, CustomerNumber
    FROM Customer WITH (NOLOCK) 
    WHERE CustomerTypeNumber = 7
    AND ISNULL(MarkAsDeleted, 0) = 0
  OPEN dbcur
  FETCH NEXT FROM dbcur INTO @NumberOfBeds, @JournalNumber, @HotelNumber, @HotelCustomerNumber

  WHILE @@FETCH_STATUS = 0
  BEGIN
    SELECT @HotelSetupNumber = HotelSetupNumber FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'NOOFBEDS'  
    IF ISNULL(@HotelSetupNumber, 0) > 0 AND ISNUMERIC(@NumberOfBeds) = 1
      EXEC UpdateHotelSetupChainSettings @HotelCustomerNumber, @HotelSetupNumber, @NumberOfBeds

    SELECT @HotelSetupNumber = HotelSetupNumber FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'JournalNo'  
    IF ISNULL(@HotelSetupNumber, 0) > 0
      EXEC UpdateHotelSetupChainSettings @HotelCustomerNumber, @HotelSetupNumber, @JournalNumber

    FETCH NEXT FROM dbcur INTO @NumberOfBeds, @JournalNumber, @HotelNumber, @HotelCustomerNumber
  END

  CLOSE dbcur
  DEALLOCATE dbcur
END