



CREATE PROCEDURE DBO.TEMPUpdateReservationAddressXTab  AS
SET NOCOUNT ON

/*
DECLARE
@AddressNumber INT,
@AddressType TINYINT

DECLARE #Cur CURSOR FAST_FORWARD FOR

  SELECT AddressNumber, AddressType FROM ReservationAddress(NOLOCK)

OPEN #Cur
FETCH NEXT FROM #Cur
INTO @AddressNumber, @AddressType

WHILE  (@@FETCH_STATUS <> -1)
BEGIN
  UPDATE ReservationAddressXTab SET AddressTypeNumber=@AddressType
  WHERE AddressNumber=@AddressNumber AND AddressTypeNumber<>@AddressType

  FETCH NEXT FROM #Cur
  INTO @AddressNumber, @AddressType
END

CLOSE #CUR
DEALLOCATE #CUR
*/

UPDATE ReservationAddressXTAB SET AddressTypeNumber=(SELECT AddressType FROM ReservationAddress WHERE ReservationAddress.AddressNumber=ReservationAddressXTAB.AddressNumber)

