top of page
Search
Kunal Ranpura
Jan 12, 20201 min read
Script to Remove Replication SQL Server
--Set deadlock priority to high to make sure the script is not stopped due to deadlock SET DEADLOCK_PRIORITY HIGH --<numeric-priority>...
351 views0 comments
Kunal Ranpura
Jan 12, 20201 min read
Script to Check log reuse wait type in sql server
--Find log_reuse_wait_desc wait type for the database: DB_Name select log_reuse_wait_desc from sys.databases where name='DB_Name'
86 views0 comments
Kunal Ranpura
Jan 12, 20201 min read
Script to Remove Data or Log File
--Note: Check is required if you want to remove log file. Only Secondary log file and data file can be removed. checkpoint go USE...
12 views0 comments
Kunal Ranpura
Jan 12, 20201 min read
Change Data Capture
--List of tables with CDC enabled SELECT s.name AS Schema_Name, tb.name AS Table_Name , tb.object_id, tb.type, tb.type_desc,...
32 views0 comments
Kunal Ranpura
Dec 24, 20191 min read
Script to Fix Orphan Users in SQL Server
--Find Orphan Users in the DB EXEC sp_change_users_login 'Report' --If you already have a login created, map the user to login using the...
83 views0 comments
Kunal Ranpura
Dec 24, 20191 min read
SQL Server Change DB Owner to SA
SQL Server Script to Change DB Owner to SA for all the user DBs in the Instance. --Script:17 Change DB Owner to SA for all the User DBs...
51 views0 comments
Kunal Ranpura
Dec 13, 20191 min read
SQL Server Configure Distributed Transaction Coordinator (DTC)
Learn how to configure DTC
73 views0 comments
Kunal Ranpura
Dec 7, 20193 min read
SQL Server Log Shipping Using T-SQL
T-SQL Script to Log Shipping Database. Pre-req. Check List: Database should be in Full recovery mode. Take Full database back on the...
900 views0 comments
Kunal Ranpura
Nov 30, 20192 min read
SQL Server Database Mirroring
Learn how to configure SQL Server database mirroring using T-SQL Script.
735 views0 comments
Kunal Ranpura
Nov 16, 20192 min read
SQL Server 2019 Accelerated Database Recovery ADR
SQL 2019 has a new feature name: ADR Accelerated Database Recovery. To enable ADR at database level: alter database wideworldimportersdw...
589 views0 comments
Kunal Ranpura
Nov 16, 20191 min read
SQL Server Log LSN Details
select top 10 * from sys.fn_dblog(null,null) order by [Current LSN] desc go
14 views0 comments
Kunal Ranpura
Nov 10, 20191 min read
Find Object associated with SQL Server Latch Wait Type
--Script:16 SQL Server 2019 and Above. Find DB and Object name having Page_latch Wait type. --You can use the following script as an...
15 views0 comments
Kunal Ranpura
Oct 23, 201910 min read
PowerShell Function to Automate Monitoring
clear #Install-Module ImportExcel #output file location: c:\powershell\Report_PROD_.xlsx #Input File C:\powershell\sqlservers.txt...
137 views0 comments
Kunal Ranpura
Oct 23, 20191 min read
SQL Server: Find Available Space in Data & Log files for all DBs in an instance
SET ANSI_NULLS ON; SET ARITHABORT ON; SET QUOTED_IDENTIFIER ON; SET NOCOUNT ON; Declare @dbname varchar(max) DECLARE @command...
13 views0 comments
Kunal Ranpura
Aug 13, 20194 min read
5 - Scripts I use every single day
1). Script to see what is running in your SQL Server. select * from sys.sysprocesses where status = 'suspended' and spid >10 and hostname...
50 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
SQL Server Index Read/Write stats (all tables in current DB) ordered by Writes
SELECT OBJECT_NAME(s.[object_id]) AS [ObjectName], i.name AS [IndexName], i.index_id, s.user_updates AS [Writes], user_seeks + user_scans...
15 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
SQL Server Index Read/Write stats (all tables in current DB) ordered by Reads
SELECT OBJECT_NAME(s.[object_id]) AS [ObjectName], i.name AS [IndexName], i.index_id, user_seeks + user_scans + user_lookups AS [Reads],...
9 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
Find when index statistics where last updated
-- When were Statistics last updated on all indexes? SELECT o.name, i.name AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS...
10 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
SQL Server Find what Objects are using space in buffer cache
-- Breaks down buffers used by current database by object (table, index) in the buffer cache SELECT OBJECT_NAME(p.[object_id]) AS...
22 views0 comments
Kunal Ranpura
Aug 12, 20191 min read
SQL Server missing indexes from cached plans in the current database
-- Find missing index warnings for cached plans in the current database -- Note: This query could take some time on a busy instance...
9 views0 comments
bottom of page