Arithmetic overflow error converting expression to data type varchar.

Let’s try following command to get this error:

SELECT CAST( CAST(virtual_memory_in_bytes AS VARCHAR(5)) AS DECIMAL(5,2))
FROM sys.dm_os_sys_infoWe can fix this using a perfect CAST statement:select CAST(virtual_memory_in_bytes AS DECIMAL(15,2))/(1024*1024*1024)
from  sys.dm_os_sys_info

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s