The code you have will work if IPADDRESS was bigint (effectively storing the unsigned int representation in the database, i.e. all values> 0). Do you have the ability to change the data type in a table?
To get what you need, you need to convert the signed int to the equivalent unsigned int before converting to bigint. I'm not sure which is the most efficient way to do this in TSQL, but it could be disabling it in binary:
SELECT dbo.IPADDRESS.IPADDRESS, CAST(ROUND( (cast(cast(dbo.IPADDRESS.IPADDRESS as binary(4)) as bigint) / 16777216 ), 0, 1) AS varchar(4)) + '.' + CAST((ROUND( (cast(cast(dbo.IPADDRESS.IPADDRESS as binary(4)) as bigint) / 65536 ), 0, 1) % 256) AS varchar(4)) + '.' + CAST((ROUND( (cast(cast(dbo.IPADDRESS.IPADDRESS as binary(4)) as bigint) / 256 ), 0, 1) % 256) AS varchar(4)) + '.' + CAST((cast(cast(dbo.IPADDRESS.IPADDRESS as binary(4)) as bigint) % 256 ) AS varchar(4)) as IPDottedNotation
source share