Error converting numeric only text string to int in SQL Server Management Studio 2008
<p>I'm having a problem converting a number stored as a varchar to an int or decimal using the cast or convert function.</p>

<p>All other research I have done on this error suggests I must have non numeric characters in my text string, but as far as I am aware there are only valid numeric characters.</p>

<p>I have had to import numbers as a string from a csv file with double quotes, such as "202,918".</p>

<p>I have then updated the table to add a new column removing the comma and double quotes to get a text string of 202918 using:</p>

<pre><code>UPDATE dbo.Table_Name
SET New_column = replace(replace(Original_column,'"',''),',','')
</code></pre>

<p>This is giving me the following data:</p>

<p>New_column 202918 243813 962 11335 6108 2106 3 2 614 263 468124</p>

<p>I am then trying to convert this to numeric value using </p>

<pre><code>select cast([New_column] AS int) from dbo.Table_Name 
</code></pre>

<p>and getting</p>

<blockquote>
<pre><code>Syntax error converting the nvarchar value '202918
' to a column of data type int.
</code></pre>
</blockquote>

<p>or</p>

<pre><code>select cast([New_column] AS decimal(20,0)) from dbo.Table_Name 
</code></pre>

<p>and getting</p>

<blockquote>
  <p>Error converting data type nvarchar to numeric.  </p>
</blockquote>

<p>Please can anybody help?</p>