Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Raiserror and numeric parameters (real, float)
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01226806
Message ID:
01226883
Vues:
12
This message has been marked as a message which has helped to the initial question of the thread.
>Borislav,
>
>>No need of LTRIM(STR(....)) if you CAST the variable to varchar()
>
>I need to show this information with two decimals. Using Varchar, returns it with 3 decimals.
>
>In addition, Brazilians use , (common) as decimal separator, and Cast returns . (point) as decimal separator.
>
>Any way, thanks for your answer... I'm still learning SQL and this kind of tips are very interesting to learn!
>
>Thanks!
>
>Rodolfo

CAST will return 3 decimals only if your VAR is defined as Numeric(9,3), if it is defined as Numeric(9,2) it will return 2 decimals:
declare @var1 as Numeric(9,3), @var2 as Numeric(9,2)
SET @var1 = 1.12
SET @var2 = 1.12
SELECT CAST(@var1 as varchar(200)),CAST(@var2 as varchar(200))
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform