Problem Statement: Script to find top 10 high memory consuming Queries. Solution: SELECT TOP 10 Object_name(qt.objectid) AS ‘SP Name’, Substring(qt.text, ( qs.statement_start_offset / 2 ) + 1, ( ( CASE qs.statement_end_offset WHEN -1 THEN Datalength(qt.text) ELSE qs.statement_end_offset END[…]
Read moreCategory: Scripts
SQL Server Agent- Get Avg Jobs Run Time
Problem Statement: Script to find average SQL Server Agent jobs run time. Solution: SET TRANSACTION isolation level READ uncommitted; WITH cte_AR AS (SELECT j.NAME AS ‘JobName’, Cast(( ( run_duration / 10000 * 3600 + ( run_duration / 100 )%100 * 60 + run_duration%100 + 31 ) / 60.0 ) AS DECIMAL(18, 2)) AS[…]
Read moreMSSQL Server: Get VLF counts of all Dbs
Problem Statement:Get the VLF count of all the dbs in a SQL server Instance. Solution: –variables to hold each ‘iteration’ DECLARE @query VARCHAR(100) DECLARE @dbname SYSNAME DECLARE @vlfs INT –table variable used to ‘loop’ over databases […]
Read more