IF NOT EXISTS(SELECT * FROM IdentityFields WHERE DBTableName = 'CashBoxReportPrintIdentity')
BEGIN
  DECLARE @HotelCustomerNumber INT
  
  DECLARE db_cur CURSOR FOR
    SELECT CustomerNumber FROM Customer WITH (NOLOCK) WHERE CustomerTypeNumber = 7 AND ISNULL(MarkAsDeleted, 0) = 0 AND HotelNumber >= 0
  OPEN db_cur
  
  FETCH NEXT FROM db_cur INTO @HotelCustomerNumber
  
  WHILE @@FETCH_STATUS = 0
  BEGIN
    INSERT INTO IdentityFields (DBTableName, HotelCustomerNumber, IdentityField, FKDepartment, Changedate) VALUES ('CASHBOXREPORTPRINTIDENTITY', @HotelCustomerNumber, 0, -1, GETDATE())
    FETCH NEXT FROM db_cur INTO @HotelCustomerNumber
  END
  CLOSE db_cur
  DEALLOCATE db_cur
END