T-SQL query To Get Buffer Cache Hit Ratio in SQL Server

Wondering how to find out Buffer Cache Hit Ratio on SQL Server?

Below is a T-SQL script to get the Buffer Cache Hit Ratio on a SQL Server.

SELECT cast((cast(((dopc.cntr_value * 1.0 / sdopc.cntr_value) * 100.0) as decimal(8,5))) as varchar(20)) + '%' AS [BUFFER CACHE HIT RATIO]
FROM sys.dm_os_performance_counters AS dopc
INNER JOIN (SELECT cntr_value, [object_name]
            FROM sys.dm_os_performance_counters  
            WHERE counter_name = N'Buffer cache hit ratio base'
            AND [object_name] = N'SQLServer:Buffer Manager') AS sdopc 
ON dopc.[object_name] = sdopc.[object_name]
WHERE dopc.counter_name = N'Buffer cache hit ratio'
AND dopc.[object_name] = N'SQLServer:Buffer Manager'