Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating a numeric field with a character field
Message
 
 
À
29/10/2014 10:36:31
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01610090
Message ID:
01610100
Vues:
38
This message has been marked as a message which has helped to the initial question of the thread.
>>It should unless you have not numeric data. What error do you get?
>
>After verification, while the command to CAST as INT would work, one of the records has a special character in it, probably an error in the code at some time, which allowed non numeric value to be entered in that field. So, I would need to look for a more enhanced command to convert only numeric values, and if a non-digit character is found in the field, to consider that as 0.

Use ISNUMERIC() function
UPDATE Client SET Amount2 = 
CASE WHEN ISNUMERIC(Amount ) = 1 THEN CAST(Amount AS INT) ELSE 0 END)
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform