Get the greatest value in a nvarchar column
<p>I'm developing a database with SQL Server 2012 SP2.</p>

<p>I have a table with a NVARCHAR(20) column, and it will have numbers: "000001", "000002", etc.</p>

<p>I need to get the greatest value in that column and convert it to int. How can I do it?</p>

<p>I have found that I can convert a nvarchar to int with this sql sentence:<br/>
<code>SELECT CAST(YourVarcharCol AS INT) FROM Table</code></p>

<p>But I don't know how can I get the max value in that column because the numbers are nvarchar.</p>

<p><strong>UPDATE:</strong><br/></p>

<p>By the way, this column is NVARCHAR because I need to store text on it. I'm testing my solution and I need to store <strong>ONLY</strong> numbers to test it.</p>