SET NOCOUNT ON

DECLARE @ID INT

SELECT * FROM CancellationCodes WITH (NOLOCK) WHERE Text = 'OTA INTERFACE'
IF @@rowcount = 0
BEGIN
  INSERT INTO CancellationCodes
           (Text,            CancellationCodeType, NoteRequired) 
    VALUES ('OTA INTERFACE', 3 /*cctReservation*/, 0           )
END
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'FK_DefaultTurnawayCode'
    WHERE SysObjects.Name = 'CustomerOTA'
)
  ALTER TABLE CustomerOTA ADD FK_DefaultTurnawayCode INT NULL 
GO

UPDATE CustomerOTA 
SET FK_DefaultTurnawayCode = @@IDENTITY
WHERE FK_DefaultTurnawayCode IS NULL