top of page

Search
SQL Server object with most latch contention
SELECT TOP (5) a.database_id, so.object_id, so.name AS TableName, a.page_latch_wait_count , a.page_latch_wait_in_ms,...

Kunal Ranpura
Jul 28, 20191 min read
Table Used most in SQL Server
SELECT TOP (5) b.name AS TableName, a.database_id, a.singleton_lookup_count, a.range_scan_count FROM sys.dm_db_index_operational_stats(...

Kunal Ranpura
Jul 28, 20191 min read
Query to find the sql authentication Scheme in SQL Server
--Query to find the sql authentication Scheme SELECT auth_scheme FROM sys.dm_exec_connections WHERE session_id = @@spid

Kunal Ranpura
Jul 28, 20191 min read
Find Storage Latency in SQL Server
SELECT [ReadLatency] = CASE WHEN [num_of_reads] = 0 THEN 0 ELSE ([io_stall_read_ms] / [num_of_reads]) END, [WriteLatency] = CASE WHEN...

Kunal Ranpura
Jul 28, 20191 min read
Fix Orphan User
--Fix Orphan Users EXEC sp_change_users_login 'Report' EXEC sp_change_users_login 'Auto_Fix', 'user' EXEC sp_change_users_login...

Kunal Ranpura
Jul 28, 20191 min read
SQL Server Page Split/Sec using DMV
--Page Split/Sec using DMV SELECT ms_ticks FROM sys.dm_os_sys_info; Select * from sys.dm_os_performance_counters where object_name =...

Kunal Ranpura
Jul 28, 20191 min read
Find who uses the most query memory grant in SQL Server
---Find who uses the most query memory grant: SELECT mg.granted_memory_kb, mg.session_id, t.text, qp.query_plan FROM...

Kunal Ranpura
Jul 28, 20191 min read
SQL Server Average Stall Per IO
-- Calculates average stalls per read, per write, and per total input/output for each database file. SELECT DB_NAME(fs.database_id) AS...

Kunal Ranpura
Jul 28, 20191 min read
Find Last Full Backup SQL Server
--Find last backup time for all the DB SELECT sdb.Name AS DatabaseName, COALESCE(CONVERT(VARCHAR(12), MAX(bus.backup_finish_date),...

Kunal Ranpura
Jul 28, 20191 min read
Query to find page life expectency in SQL Server
SELECT @@servername AS INSTANCE ,[object_name] ,[counter_name] , UPTIME_MIN = CASE WHEN[counter_name]= 'Page life expectancy' THEN...

Kunal Ranpura
Jul 28, 20191 min read
Find Details about Index
sp_helpindex 'index_name'

Kunal Ranpura
Jul 28, 20191 min read
Index Disable Compression
ALTER INDEX ALL ON <TABLE NAME> REBUILD WITH (DATA_COMPRESSION = None);

Kunal Ranpura
Jul 28, 20191 min read
Get list of compressed objects in database
-- Run the script below on the database which is suspected to have compressed objects to get the details of the objects enabled for data...

Kunal Ranpura
Jul 28, 20191 min read
Check Database Isolation Level
DBCC useroptions

Kunal Ranpura
Jul 28, 20191 min read
Find Table Size
sp_spaceused ‘Tablename’

Kunal Ranpura
Jul 28, 20191 min read
SQL Server List Database Schemas
1 a). SELECT name FROM sys.schemas 1 b). SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA

Kunal Ranpura
Jul 28, 20191 min read
SQL Server Audit
--Auditing Scripts 1). Find Sysadmin accounts USE master go SELECT name FROM syslogins WHERE sysadmin = 1 2). find logins account that...

Kunal Ranpura
Jul 28, 20191 min read
Check Database Data File and its Filegroup
--Check DB file and its filegroup select * from sys.filegroups go select * from sys.database_files

Kunal Ranpura
Jul 28, 20191 min read
Script Find DB File Growth for all the databases
select name, physical_name, size*0.000008 Size_GB, growth, is_percent_growth, growth*0.0078125 Growth_MB from sys.master_files order by...

Kunal Ranpura
Jul 28, 20191 min read
Execution Plan of Cached Queries
----Get execution plan of cached queries orderd by Total Elapsed Time Desc SELECT total_logical_reads, total_logical_reads /...

Kunal Ranpura
Jul 28, 20191 min read
bottom of page





