Skip to content
Advertisement

how to Convert nvarchar to int

I need to get data according to nvarchar coloumn that holds numbers,I get this error: Conversion failed when converting the nvarchar value ‘362X’ to data type int. I tried this:

What am I missing ?

Advertisement

Answer

In SQL Server, you can use try_convert() or try_cast():

In other databases, you can use a case perhaps with regular expressions:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement