title: SQL Server: How do I get the highest value not set of an int column?
body: <p>Let's take an example. These are the rows of the table I want get the data:</p>
  
  <p><a href="https://i.stack.imgur.com/tXkja.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tXkja.jpg" alt="enter image description here"></a></p>
  
  <p>The column I'm talking about is the <code>reference</code> one. The user can set this value on the web form, but the system I'm developing must suggest the lowest <code>reference</code> value still not used. </p>
  
  <p>As you can see, the smallest value of this column is 35. I could just take the smaller reference and sum 1, but, in that case, the value 36 is already used. So, the value I want is 37.</p>
  
  <p>Is there a way to do this without a loop verification? This table will grow so much.</p>