top of page

Search
SQL Server Profiler Trace
--Import multiple trace file in sql Table. --All the rollover files will be automatically imported --provide number tracefile to capture...
Kunal Ranpura
Feb 19, 20241 min read
1 view
0 comments
Find All Primary Key in SQL Server
select schema_name(tab.schema_id) as [schema_name], pk.[name] as pk_name, substring(column_names, 1, len(column_names)-1) as [columns],...
Kunal Ranpura
Apr 14, 20231 min read
6 views
0 comments
SQL Server find Database User Permission
--Execute the following script against the User Database where you need to find DB User permission. DECLARE @sql VARCHAR(2048) ,@sort INT...
Kunal Ranpura
Jan 28, 20203 min read
67 views
0 comments
SQL Server Snapshot Isolation
--Script to verify snapshot isolation enabled SELECT name , s.snapshot_isolation_state , snapshot_isolation_state_desc ,...
Kunal Ranpura
Jan 15, 20201 min read
14 views
0 comments
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,...
Kunal Ranpura
Jan 12, 20201 min read
33 views
0 comments
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...
Kunal Ranpura
Dec 24, 20191 min read
84 views
0 comments
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...
Kunal Ranpura
Dec 24, 20191 min read
55 views
0 comments
SQL Server Log LSN Details
select top 10 * from sys.fn_dblog(null,null) order by [Current LSN] desc go
Kunal Ranpura
Nov 16, 20191 min read
14 views
0 comments
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...
Kunal Ranpura
Oct 23, 20191 min read
13 views
0 comments
Find Size of all Databases in SQL Instance in GB
SELECT distinct d.name AS 'Database', SUM(m.size * 8/1024000) OVER (PARTITION BY d.name) AS 'Database Total Size GB' FROM...
Kunal Ranpura
Aug 9, 20191 min read
7 views
0 comments
Get CPU utilization by database SQL Server
-- Get CPU utilization by database WITH DB_CPU_Stats AS (SELECT DatabaseID, DB_Name(DatabaseID) AS [DatabaseName], SUM(total_worker_time)...
Kunal Ranpura
Jul 29, 20191 min read
22 views
0 comments
Recovery model, log reuse wait, log file size, log usage Fsize and compatibility level for all DB
-- Recovery model, log reuse wait description, log file size, log usage size -- and compatibility level for all databases on instance...
Kunal Ranpura
Jul 29, 20191 min read
5 views
0 comments
Volume info for all databases on the current instance SQL Server
-- Volume info for all databases on the current instance (SQL Server 2008 R2 SP1 or greater) SELECT DB_NAME(f.database_id) AS...
Kunal Ranpura
Jul 29, 20191 min read
2 views
0 comments
Find SQL Server Database Data and Log File Size in GB
SELECT DB_NAME([database_id])AS [Database Name], [file_id], name, physical_name, type_desc, state_desc, CONVERT( bigint, size/128000.0)...
Kunal Ranpura
Jul 29, 20191 min read
64 views
2 comments
Find Configuration value for your SQL Instance
-- Get configuration values for instance SELECT name, value, value_in_use, [description] FROM sys.configurations ORDER BY name OPTION...
Kunal Ranpura
Jul 29, 20191 min read
10 views
0 comments
How to Get SQL Server processor description from Windows Registry
-- Get processor description from Windows Registry EXEC xp_instance_regread 'HKEY_LOCAL_MACHINE', 'HARDWARE\DESCRIPTION\System\CentralPro...
Kunal Ranpura
Jul 29, 20191 min read
7 views
0 comments
Find Hardware Manufacturer for your SQL Server
-- Get System Manufacturer and model number from -- SQL Server Error log. This query might take a few seconds -- if you have not recycled...
Kunal Ranpura
Jul 29, 20191 min read
147 views
0 comments
Script to find SQL Server Hardware Details
SELECT cpu_count AS [Logical CPU Count], hyperthread_ratio AS [Hyperthread Ratio], cpu_count/hyperthread_ratio AS [Physical CPU Count],...
Kunal Ranpura
Jul 29, 20191 min read
10 views
0 comments
SQL Script to find SQL Service Information
-- SQL Server Services information (SQL Server 2008 R2 SP1 or greater) SELECT servicename, startup_type_desc, status_desc,...
Kunal Ranpura
Jul 29, 20191 min read
4 views
0 comments
Find OS version from SQL Server
-- Windows information (SQL Server 2008 R2 SP1 or greater) SELECT windows_release, windows_service_pack_level, windows_sku,...
Kunal Ranpura
Jul 29, 20191 min read
10 views
0 comments
bottom of page