SQL query error when executing

1

I am trying to make a query in SQL Server in which I do:

Round(Convert(float,A)/(Convert(float,B),2)

and you return this message:

  

The conversion of the nvarchar value '2968922618' overflowed an int column.

The value of the denominator is:

  • b = 4841517826

If I delete the number 6, the last digit works perfectly. But if not, it fails. Any ideas?

    
asked by ignacio blanco gonzalez 22.02.2017 в 16:17
source

1 answer

1

It is because the maximum value that a INT field can receive is 2,147,483,647 and you are trying to assign 2,968,922,618 . Try making CAST to BIGINT :

Cast(Round((Convert(float,A)/Convert(float,B)),2) as bigint)
    
answered by 22.02.2017 в 17:00