Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting nvarcher to numeric
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00490968
Message ID:
00490990
Views:
9
>When I using CONVERT function to convert nvarchar to numeric, I getting error message "Error converting data type nvarchar to numeric".
>I read help, and figured out that it is because there is charachters inside nvarchar variable.
>But is it possible to convert the same variables without errors, but zeros instead? :)

Not sure if this is exactly what you want, but you could use a CASE statement and check if the value is numeric and if so, convert it. Otherwise, throw in a 0.

Ex.

select 'newvalue' = case isnumeric(@var1) when 0 then 0 else cast(@var1 as numeric(10)) end

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform