Azure Data Studio – My result is rounded – SQL

The data type of the variable is irrelevant in this case, it’s the target of the result – you’re using literal values which are implicitly integers.

If you define at least one of the arguments to be a decimal type then data-type precedence will ensure the result is also a decimal:

declare @Cute decimal(10, 3) = 10.0 / 3;
select @Cute;

You could also use the definied variable as one of the arguments, the same data type precedence then applies, such as

declare @Cute decimal(10, 3) = 10;
set @cute = @cute / 3;
select @Cute;

Read more here: Source link