We have script to calculate the free space of all the Databases . Most of the time sript is running run and giving the results . But few times it's getting failed with below error . Please advise how to modify the script ( So that it will convert it without any issues ) . Msg 247, Level 16, State 1: Server 'SMART_DEV', Line 3: Arithmetic overflow during explicit conversion of NUMERIC value '116.2109375000000000' to a DECIMAL field . (Couple of databaes getting results and while converting for other database it's giving this error message . Please help to fix the exixting script ) Please find the script : set nocount on select convert(nchar(20), getdate()) "Date & Time", convert(nchar(11), db_name(dbid))||" DB Space left" "Database name", sum(curunreservedpgs(dbid,lstart,unreservedpgs))*4 "Free KB", convert(decimal(4,2), (sum(curunreservedpgs(dbid,lstart,unreservedpgs))*4.00)/1024.00/1024.00) "Free GB", 129 "Total GB", convert(decimal(5,2), ((sum(curunreservedpgs(dbid,lstart,unreservedpgs))*4.00)/1024.00/1024.00)*100.00/129.00) "Free %" from sysusages where dbid = 4 and segmap = 3 group by db_name(dbid) union all select convert(nchar(20), getdate()) "Date & Time", convert(nchar(11), db_name(dbid))||" LOG Space left" "Database name", sum(curunreservedpgs(dbid,lstart,unreservedpgs))*4 "Free KB", convert(decimal(4,2), (sum(curunreservedpgs(dbid,lstart,unreservedpgs))*4.00)/1024.00/1024.00) "Free GB", 17 "Total GB", convert(decimal(5,2), ((sum(curunreservedpgs(dbid,lstart,unreservedpgs))*4.00)/1024.00/1024.00)*100.00/17.00) "Free %" from sysusages where dbid = 4 and segmap = 4 group by db_name(dbid) union all
↧