Fix Error Msg 237 “There is insufficient result space to convert a money value to int” in SQL Server

If you’re getting error msg 237 that reads There is insufficient result space to convert a money value to int, it’s because you’re trying to convert a money value to an integer but the number’s too big to fit into an integer.

To fix this issue, make sure you convert the value to a data type that can handle the size of the number that you’re trying to convert.

Example of Error

Here’s an example of code that results in the error:

DECLARE @bank_balance money = 2147483648;
SELECT CAST( @bank_balance AS int );

Result:

Msg 237, Level 16, State 1, Line 2
There is insufficient result space to convert a money value to int.

This error occurred because I tried to convert a money value of 2147483648 to an int type. The int type can only handle values in the range -2,147,483,648 to 2,147,483,647, which is lower than the value that I passed, and so we got the error.

We get the same error when doing an implicit conversion:

DECLARE @bank_balance money = 2147483648;
DECLARE @wallet int = @bank_balance;

Result:

Msg 237, Level 16, State 1, Line 2
There is insufficient result space to convert a money value to int.

Solution

To fix the issue, we should convert to a data type that can handle the number. In our case, we can convert to a bigint type:

DECLARE @bank_balance money = 2147483648;
SELECT CAST( @bank_balance AS bigint );

Result:

2147483648