Question: I have a temporary table with datatype `NVARCHAR` which I need to migrate to a table with datatype `INTEGER`.

I have two `NVARCHAR` tables which need to be `INTEGER`, one is working and the other is giving an error,

> 
> Conversion failed when converting the nvarchar value '9824  
> 
>  ' to data type int.
> 
> 
> 

I tried removing that extra space using `LTRIM` and `RTRIM` but `ISNUMERIC()` is still giving 0 and the error stays the same.

This is the code resulting in an error,

```
SELECT CAST(table_name AS integer)
FROM OLTP.table

```

What I've tried:

```
SELECT ISNUMERIC(REPLACE(Revenue, ' ', '')), Revenue, ISNUMERIC(REPLACE(LTRIM(RTRIM(Revenue)), '  ', ' '))
FROM OLTP.ExtractedData

```

Sample Data

```
(No column name)    Revenue (No column name)
0   9824    0
0   5661    0
0   3250    0
0   2959    0
0   2511    0
0   2072    0
0   2056    0
0   1705    0
0   1704    0

```

Answer: 
You probably have a linebreak in there, TRIM/RTRIM don't trim those.

```
declare @value nvarchar(10) = '1234
'

select ISNUMERIC(Replace(CHAR(9), '', @value))
select ISNUMERIC(Replace(CHAR(10), '', @value))
select ISNUMERIC(Replace(CHAR(13), '', @value))
select ISNUMERIC(Replace(CHAR(32), '', @value))

```
Instead of `cast()` use `try\_cast()

```
SELECT TRY_CAST(table_name AS integer)
FROM OLTP.table

```