Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting nvarcher to numeric
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00490968
Message ID:
00490990
Vues:
10
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform