Sqlserver
 SQL >> Database >  >> RDS >> Sqlserver

Tre modi per trasformare un intero in decimale in SQL Server

Puoi convertire un intero in decimale con CAST(), CONVERT() o una moltiplicazione implicita.

SELECT CAST(275 AS DECIMAL(5,2));
SELECT CONVERT(DECIMAL(5,2), 275);
SELECT 275 * 1.00;

Attenzione alla precisione: se il numero è troppo grande per il tipo decimale, SQL Server restituisce Msg 8115.