DECLARE @sql NVARCHAR(1000)
IF EXISTS
(
  SELECT SysColumns.Name
  FROM SysObjects WITH (NOLOCK)
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID
    AND SysColumns.Name = 'FKRateLevelChannelId'
    WHERE SysObjects.Name = 'OTAInvCountNotifHallLog'
)
BEGIN
  SET @sql = 'DELETE FROM OTAInvCountNotifHallLog WHERE ISNULL(FKRateLevelChannelId, -1) = -1'
  EXEC sp_executesql @sql
END