Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with integer conversion
Message
 
 
À
11/09/2013 21:51:41
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 6.5 and older
Application:
Web
Divers
Thread ID:
01582916
Message ID:
01582932
Vues:
44
>Don,
>
>Exactly as Charles said, you want to round the number to get rid of decimals. The integer data type is constrained to only store whole numbers.
>
>Just to demonstrate in SSMS: This won't work...
>
>
>SELECT CAST( '123.45' AS INT)  -- GENERATES AN ERROR
>
>
>But this will work:
>
>
>SELECT CAST(  ROUND('123.45',0) AS INT)   -- GENERATES 123
The original problem is because he used AddWithValue and the parameter was send as varchar. If he would use Add and exact type, this would not happen.

BTW, this works
SELECT CAST( 123.45 AS INT)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform