4

I am new to SQL Server, this question might be repeated here. Since i haven't find a solution for my problem. I wished to post here. So here is my problem

select(volume * speed)  from traffic_data_replica;

I am trying to multiply values from two columns , data type is smallint for both columns. Error i got is :

Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type smallint.

1 Answer 1

7

Cast one of the values to a "bigger" type before the calculation:

select cast(volume as int) * speed
from traffic_data_replica;

You can also do this easily by multiplying by 1.0:

select 1.0*volume*speed
from  traffic_data_replica
Sign up to request clarification or add additional context in comments.

1 Comment

This was really a good information :) @Gordon Linoff Really thankful to you . "Information is wealth"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.