IF EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'SubType2'
    WHERE SysObjects.Name = 'Followup'
)
BEGIN
  IF NOT EXISTS (SELECT TOP 1 * FROM Followup WITH (NOLOCK) WHERE NOT SubType2 IS NULL)
  BEGIN
    DECLARE @dt datetime
    SET @dt = GETDATE()
    SET @dt = DATEADD(YEAR, -2, @dt)

    UPDATE Followup
    SET SubType2 = 2 -- fst2Precharge
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND Note LIKE 'Precharge.'

    UPDATE Followup
    SET SubType2 = 3 -- fst2Allocation
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND Note LIKE 'BookRoom: %'
  
    UPDATE Followup
    SET SubType2 = 4 -- fst2Checkin
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND (Note LIKE 'Checkin via subres (%' OR Note LIKE 'Checkin (%' OR Note LIKE 'Checkin when creating namelist because it came from an already inhouse main reservation.' 
      OR Note LIKE 'Checkin' OR Note LIKE 'Checked In' OR Note LIKE 'Court Checked In')

    UPDATE Followup
    SET SubType2 = 5 -- fst2CheckinTable
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND Note LIKE 'Checkin (Table%'

    UPDATE Followup
    SET SubType2 = 6 -- fst2Checkout
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND (Note LIKE 'Checkout (%' OR Note LIKE 'Checkout')

    UPDATE Followup
    SET SubType2 = 7 -- fst2EarlyPayOut
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND Note LIKE 'Early-Pay/Out.'

    UPDATE Followup
    SET SubType2 = 8 -- fst2GDPRMailSend
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND Note LIKE 'Sending GDPR mail by%'

    UPDATE Followup
    SET SubType2 = 9 -- fst2SMSSend
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND Note LIKE 'SMS: Tel: (%'
 
    UPDATE Followup
    SET SubType2 = 10 -- fst2BillCreated
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND Note LIKE 'Bill created by Mona Longstay.'

    UPDATE Followup
    SET SubType2 = 11 -- fst2CheckoutBatch
    WHERE SubType2 IS NULL
    AND Date >= @dt
    AND Note LIKE 'Checkout by CheckoutBatch'
  END
END