I'm getting this error 8115, which is the dreaded converting issue.
The problem is I'm not associating it to a particular value, just counting and using a mulitplier. If you remove those two lines where I got (fails here) it runs fine. I've tried converting it to a bigint, int, and isnumeric but no solution as of yet, any advice?
SELECT
obj.name as tblname,
i.name as indname,
i.type_desc,
count(*)AS Buffered_Page_Count,
case when ISNUMERIC(count(*) * 8192 / (1024 * 1024) ) <> 1 then NULL else count(*) * 8192 / (1024 * 1024) end as 'MB_size' (fails here)
--isnull(cast((cast(count(*)* 8192/(1024*1024)as FLOAT))as BIGINT),0) as MB_size (fails here)
FROM sys.dm_os_buffer_descriptors AS bd
INNER JOIN
(
SELECT object_name(object_id) AS name
,index_id ,allocation_unit_id, object_id
FROM sys.allocation_units AS au
INNER JOIN sys.partitions AS p
ON au.container_id = p.hobt_id
AND (au.type = 1 OR au.type = 3)---table objects
UNION ALL
SELECT object_name(object_id) AS name
,index_id, allocation_unit_id, object_id
FROM sys.allocation_units AS au
INNER JOIN sys.partitions AS p
ON au.container_id = p.hobt_id
AND au.type = 2---table objects
) AS obj
ON bd.allocation_unit_id = obj.allocation_unit_id
LEFT JOIN sys.indexes i on i.object_id = obj.object_id AND i.index_id = obj.index_id
WHERE database_id = db_id() and obj.name not like 'sys%'
GROUP BY obj.name, obj.index_id , i.name,i.type_desc
The problem is I'm not associating it to a particular value, just counting and using a mulitplier. If you remove those two lines where I got (fails here) it runs fine. I've tried converting it to a bigint, int, and isnumeric but no solution as of yet, any advice?
SELECT
obj.name as tblname,
i.name as indname,
i.type_desc,
count(*)AS Buffered_Page_Count,
case when ISNUMERIC(count(*) * 8192 / (1024 * 1024) ) <> 1 then NULL else count(*) * 8192 / (1024 * 1024) end as 'MB_size' (fails here)
--isnull(cast((cast(count(*)* 8192/(1024*1024)as FLOAT))as BIGINT),0) as MB_size (fails here)
FROM sys.dm_os_buffer_descriptors AS bd
INNER JOIN
(
SELECT object_name(object_id) AS name
,index_id ,allocation_unit_id, object_id
FROM sys.allocation_units AS au
INNER JOIN sys.partitions AS p
ON au.container_id = p.hobt_id
AND (au.type = 1 OR au.type = 3)---table objects
UNION ALL
SELECT object_name(object_id) AS name
,index_id, allocation_unit_id, object_id
FROM sys.allocation_units AS au
INNER JOIN sys.partitions AS p
ON au.container_id = p.hobt_id
AND au.type = 2---table objects
) AS obj
ON bd.allocation_unit_id = obj.allocation_unit_id
LEFT JOIN sys.indexes i on i.object_id = obj.object_id AND i.index_id = obj.index_id
WHERE database_id = db_id() and obj.name not like 'sys%'
GROUP BY obj.name, obj.index_id , i.name,i.type_desc