What you appear to be trying to do is "find a gap in a sequence" using SQL.
If I replicate your data as
create table temp
(
ChNo int
)
insert into temp values (11),(12),(13),(15), (17),(20)
The following query will return
14<br />
SELECT TOP 1 ChNo + 1
FROM temp mo
WHERE NOT EXISTS
(
SELECT NULL
FROM temp mi
WHERE mi.ChNo = mo.ChNo + 1
)
ORDER BY
ChNo
Adapted from the accepted answer to
this post[
^]
Other solutions are discussed
here[
^]