DECLARE @ArrLineNumber INT
DECLARE @WareNumber INT
DECLARE @HasCreateTable BIT

DECLARE TmpCursor CURSOR FOR
  SELECT DISTINCT WareNumber 
  FROM ArrangementLines WITH (NOLOCK) 
  WHERE ISNULL(ArrangementLines.WareHasCreateTable, 0) = 0
OPEN TmpCursor

FETCH NEXT FROM TmpCursor INTO @WareNumber

WHILE (@@FETCH_STATUS <> -1) 
BEGIN
  SELECT @HasCreateTable = WareCreateTable FROM Ware WITH (NOLOCK) WHERE WareNumber = @WareNumber

  IF @HasCreateTable = 1
  BEGIN
    UPDATE ArrangementLines
    SET WareHasCreateTable = 1
    WHERE WareNumber = @WareNumber
  END
  
  FETCH NEXT FROM TmpCursor INTO @WareNumber
END
CLOSE TmpCursor
DEALLOCATE TmpCursor