Similar to LukeH's answer but it does what you asked for:
SELECT MIN(a.your_column) - 1 AS answer
FROM your_table AS a
LEFT JOIN your_table AS a2
ON a2.your_column = a.your_column - 1
LEFT JOIN tableB AS b
ON a.your_column = b.column1
WHERE a.your_column < 1000
AND b.column1 IS NULL
AND a2.your_column IS NULL
Edit:
UNION
SELECT MIN(a.your_column) + 1 AS answer
FROM your_table AS a
LEFT JOIN your_table AS a2
ON a2.your_column = a.your_column + 1
LEFT JOIN tableB AS b
ON a.your_column = b.column1
WHERE a.your_column < 1000
AND b.column1 IS NULL
AND a2.your_column IS NULL
And pick the minumum of the two values.
It still needs checking if the value 1 is available, but if you have a gap between A and B it should find A+1 and B-1 now and you could pick the smallest. Obviously A+1 is the smallest so you can just use the second part...