Skip to content

Clive Roberts

SQL Server DBA

Menu
  • Setup
  • Performance
  • Health Check
  • Troubleshooting
  • T-SQL
  • Patches
  • News
  • Audit
  • Projects

Category: Troubleshooting

Running Scripts with the sqlcmd Utility

November 25, 2026
| 1 Comment
| Question of the Day, SQL Server, Troubleshooting
Running Scripts with the sqlcmd Utility: the T-SQL from this post in SQL Server Management Studio with its results

Applies to SQL Server 2019, 2022 and 2025. The sqlcmd utility is the plain command-line way to run T-SQL against SQL Server. I mostly use it for scripts that run on a schedule: from Windows Task Scheduler, a SQL Agent CmdExec step, a deployment pipeline or a Linux cron job. It’s simple to start with,…

Read More »

Posted in Question of the Day, SQL Server, Troubleshooting 1 Comment

SQL Server Audit Failures

November 14, 2026
| No Comments
| Question of the Day, SQL Server, Troubleshooting
SQL Server Audit Failures: the T-SQL from this post in SQL Server Management Studio

Applies to SQL Server 2019, 2022 and 2025. SQL Server audit failures happen when the instance can’t write audit records to the target: the disk is full, the share has gone, or the service account has lost its permissions on the folder. What happens next is decided by one setting on the server audit, ON_FAILURE….

Read More »

Posted in Question of the Day, SQL Server, Troubleshooting

Starting SQL Server with Minimal Configuration

November 11, 2026
| 1 Comment
| Question of the Day, SQL Server, Troubleshooting
Starting SQL Server with Minimal Configuration: the T-SQL from this post in SQL Server Management Studio

Applies to SQL Server 2019, 2022 and 2025. SQL Server minimal configuration, the -f startup option, is how you get into an instance that a bad setting has stopped from starting or from being usable. It’s a recovery tool for a few minutes’ work, not a way to run the server, and the usual trouble…

Read More »

Posted in Question of the Day, SQL Server, Troubleshooting 1 Comment

Schema Locks and Online Index Maintenance

October 17, 2026
| 3 Comments
| Troubleshooting
SQL Server Troubleshooting: Schema Locks and Online Index Maintenance

Tested on SQL Server 2022 (Developer edition, single test instance). Every query takes a schema stability (Sch-S) lock on the tables it uses, and anything that changes a table’s definition needs a schema modification (Sch-M) lock. Sch-M is the most restrictive lock in SQL Server: it is incompatible with every other lock, including Sch-S. This…

Read More »

Posted in Troubleshooting 3 Comments

Collecting a Trace with SQL Profiler

October 12, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Collecting a Trace with SQL Profiler

Run SQL Server Profiler Create new trace [1] File -> [2] New Trace Connect to MS SQL Server [1] Type your server name [2] Type your credentials [3] Click “Connect” Configure options on the “General” tab [1] Choose template -> Tuning [2] Check “Save to File” (not recommended to save trace on system hard drive…

Read More »

Posted in Troubleshooting

Collecting Data with Performance Monitor

October 12, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Collecting Data with Performance Monitor

To open Performance Monitor tool press “Windows” + “R” and type “perfmon” in the command prompt, then click “OK”: To create new Data Collector Set go to the “Data Collector Sets” -> “User Defined” item, right click and point to “New”, click “Data Collector Set”: The Create new Data Collector Set Wizard starts, enter a…

Read More »

Posted in Troubleshooting

DMVs and Session Monitoring

October 12, 2026
| 1 Comment
| Troubleshooting
SQL Server Troubleshooting: DMVs and Session Monitoring

Session monitoring in SQL Server starts with a few built-in system stored procedures and dynamic management views (DMVs) that show who is connected, what they are running and who is blocking whom. Here’s a breakdown of sp_who2, its alternatives, and more advanced tools you can use: sp_who2: Quick Session Overview Purpose: Lists current user sessions,…

Read More »

Posted in Troubleshooting 1 Comment

Sleeping Processes

October 12, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Sleeping Processes

In SQL Server, a sleeping process refers to a session that is currently idle and not executing any commands. This typically means that the session has completed its execution and is waiting for the application to submit another query or batch. In the output of the Dynamic Management Views (DMVs) such as sys.dm_exec_requests and sys.dm_exec_sessions,…

Read More »

Posted in Troubleshooting

Monitoring Deadlocks

October 12, 2026
| 1 Comment
| Troubleshooting
SQL Server Troubleshooting: Monitoring Deadlocks

Monitoring deadlocks starts with capturing the deadlock graph: it shows which sessions were involved, what each was running and which resources they were waiting for. SQL Server picks one session as the victim and rolls it back with error 1205, so without a record you only see the error, not the cause. These are the…

Read More »

Posted in Troubleshooting 1 Comment

SQL Server Error Numbers

October 11, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: SQL Server Error Numbers

The full list is at https://learn.microsoft.com/sql/relational-databases/errors-events/database-engine-events-and-errors. To look up any error on the server itself: SELECT message_id, severity, is_event_logged, text FROM sys.messages WHERE language_id = 1033 AND message_id = 1222; Errors 0 to 999 Errors 1,000 to 1,999 Errors 2,000 to 2,999 Errors 3,000 to 3,999 Errors 4,000 to 4,999 Errors 5,000 to 5,999 Errors…

Read More »

Posted in Troubleshooting

SQL Locks

October 11, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: SQL Locks

Notes on locking: Understanding and Resolving SQL Server Blocking Problems: Blocking is a characteristic of any relational database management system (RDBMS) with lock-based concurrency. In SQL Server, blocking occurs when one session holds a lock on a specific resource, and another session attempts to acquire a conflicting lock on the same resource The duration and…

Read More »

Posted in Troubleshooting

High CPU Troubleshooting

October 11, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: High CPU Troubleshooting

Step 1: Is it SQL Server? The scheduler monitor ring buffer records SQL Server’s CPU use and total CPU use about once a minute for the last few hours: SELECT TOP (30) DATEADD(ms, -1 * (si.ms_ticks – rb.[timestamp]), GETDATE()) AS event_time, rb.record.value(‘(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]’, ‘int’) AS sql_cpu_pct, 100 – rb.record.value(‘(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]’, ‘int’) AS total_cpu_pct FROM (SELECT [timestamp], CONVERT(xml,…

Read More »

Posted in Troubleshooting

Performance Troubleshooting Queries

October 11, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Performance Troubleshooting Queries

You should be familiar with the basic performance objects and counters and be able to use that information to diagnose problems within a SQL Server instance. SQL Server is typically affected by the following bottlenecks: CPU Memory File I/O Indexes Locking, waits, blocking, or deadlocking Plans, queries Network You can use Performance Monitor to identify…

Read More »

Posted in Troubleshooting

SQL Server Referencing the Wrong Disk Drives

October 10, 2026
| 1 Comment
| Troubleshooting
SQL Server Troubleshooting: SQL Server Referencing the Wrong Disk Drives

Microsoft SQL Server is referencing the wrong disk drives in the Windows Registry (Regedit)? Possible causes and fixes: 1. Check SQL Server Installation Path in Registry Open Regedit (Win + R → type regedit → Enter). Go to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Look for incorrect paths under: Setup Instance Names Instance ID 2. Verify SQL Server…

Read More »

Posted in Troubleshooting 1 Comment

Repairing the WMI Provider (mofcomp)

October 10, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Repairing the WMI Provider (mofcomp)

Windows Management Instrumentation (WMI) is an infrastructure for management data and operations on Windows-based operating systems. It allows administrators to automate administrative tasks on remote computers and provides management data to other parts of the operating system and products. WMI is a set of extensions to the Windows Driver Model that provides an operating system…

Read More »

Posted in Troubleshooting

Tempdb Full or Contention

October 9, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Tempdb Full or Contention

Tempdb full or tempdb contention: two different problems that both stop an instance in its tracks, because every database shares the one tempdb. When tempdb is full, queries fail with error 1105 or 9002; with contention, sessions queue on PAGELATCH waits even though there is space. Work out which one you have first, then find…

Read More »

Posted in Troubleshooting

Single-User Mode

October 9, 2026
| 2 Comments
| Troubleshooting
SQL Server Troubleshooting: Single-User Mode

Why Use Single User Mode? The main reasons: Emergency Repairs Useful when the database is suspect, corrupt, or otherwise inaccessible. Allows running commands like DBCC CHECKDB or restoring from backup. Restore or Rollback Operations Ensures no other users interfere during a restore, rollback, or schema change. Change Database Settings Some settings (like changing the database…

Read More »

Posted in Troubleshooting 2 Comments

Failed SQL Agent Job Triage

October 9, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Failed SQL Agent Job Triage

A failed SQL Agent job is usually the first sign that something has changed: a permission, a job owner, a full disk or an availability group failover. My triage is always the same: find the failed step and its real error, check the usual causes, then rerun or stop the job. If no one was…

Read More »

Posted in Troubleshooting

Stopping a Running Job in Job Activity Monitor

October 9, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Stopping a Running Job in Job Activity Monitor

Step 1 Open Microsoft SQL Server Management Studio and click SQL Server Agent. Step 2 Click Job Activity Monitor Step 3 Check Job status, if still running Step 4 Click on Job, that is running, and stop it. Step 5 The Job stopped From my SQL Server DBA handbook.

Read More »

Posted in Troubleshooting

Shrinking Transaction Logs

October 9, 2026
| 1 Comment
| Troubleshooting
SQL Server Troubleshooting: Shrinking Transaction Logs

Shrinking SQL Server transaction logs is a common task for DBAs, especially when logs grow unexpectedly large. Here’s a step-by-step guide to help you manage and shrink them safely: If the log is full, start with Transaction Log Full. Shrinking does not fix a full log. Before shrinking transaction logs Check what is stopping the…

Read More »

Posted in Troubleshooting 1 Comment

Data File Full and Disk Space (Error 1105)

October 9, 2026
| 1 Comment
| Troubleshooting
SQL Server Troubleshooting: Data File Full and Disk Space (Error 1105)

Error 1105 means SQL Server could not allocate space because a filegroup is full. Error 9002 is the transaction log equivalent (see Transaction Log Full). Either the file has hit its maximum size or growth setting, or the volume itself is full. Step 1: File sizes, space used and growth settings USE [YourDB]; SELECT f.name,…

Read More »

Posted in Troubleshooting 1 Comment

Transaction Log Full

October 8, 2026
| 1 Comment
| Troubleshooting
SQL Server Troubleshooting: Transaction Log Full

A transaction log full error (9002) means something is stopping SQL Server from reusing log space, and until it’s cleared, the database can’t accept any changes. Find that cause first, because shrinking transaction logs does not fix a full log. If the data file is the one full, see Data File Full and Disk Space…

Read More »

Posted in Troubleshooting 1 Comment

Shrinking Databases

October 8, 2026
| No Comments
| Troubleshooting
SQL Server Troubleshooting: Shrinking Databases

If there is unused space, it will be already used “to insert and update some new data”, and if there isn’t doing shrink will change nothing: shrink does not delete your data, all it does is moving data at the beginning of the file to make space at the end to give it back to…

Read More »

Posted in Troubleshooting

Database Suspect, Recovery Pending or Stuck Recovering

October 8, 2026
| 1 Comment
| Troubleshooting
SQL Server Troubleshooting: Database Suspect, Recovery Pending or Stuck Recovering

A database suspect, recovery pending or stuck recovering is not ONLINE, and nothing can use it until you work out why. The state tells you which path to follow: wait, fix a missing file, or restore from backup. Microsoft explains each state in its database states documentation. Step 1: Find databases that are not online…

Read More »

Posted in Troubleshooting 1 Comment

Kill All User Sessions in a SQL Server Database

March 30, 2017
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Kill All User Sessions in a SQL Server Database

Kills every user session in one database, for example before a restore. Set the database name and run it first with @Apply = 0 to see the KILL commands it would run; set @Apply = 1 to run them. Your own session is skipped. Works on SQL Server 2016 to 2022 and later. — Kill…

Read More »

Posted in SQL Server, Troubleshooting

sp_who3: sp_who2 with SQL Text, Waits and Reads

October 31, 2016
| No Comments
| Setup, Troubleshooting
SQL Server Troubleshooting: sp_who3: sp_who2 with SQL Text, Waits and Reads

sp_who3 works like sp_who2 but adds the running SQL text, wait type, reads, writes and elapsed time, using the sys.dm_exec_sessions and sys.dm_exec_requests DMVs. It only lists sessions that are running a request. For much more detail use Adam Machanic’s sp_WhoIsActive. Tested on SQL Server 2017 and 2025 and safe to run more than once. USE…

Read More »

Posted in Setup, Troubleshooting

Who Is Connected to SQL Server? (T-SQL)

May 1, 2016
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Who Is Connected to SQL Server? (T-SQL)

Who is connected, to which database, from where. Uses sys.dm_exec_sessions, which replaces the old sys.sysprocesses view. Works on SQL Server 2016 to 2022 and later. — Connections per database and login (SQL Server 2016-2022) SELECT DB_NAME(s.database_id) AS [Database Name], s.login_name AS [Login Name], s.host_name AS [Host Name], s.program_name AS [Program Name], COUNT(*) AS [No Of…

Read More »

Posted in SQL Server, Troubleshooting

Fix “Cannot Connect to WMI Provider” in Configuration Manager

February 19, 2016
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Fix "Cannot Connect to WMI Provider" in Configuration Manager

Error message when you open SQL Server Configuration Manager in SQL Server: “Cannot connect to WMI provider. You do not have permission or the server is unreachable” https://support.microsoft.com/en-us/kb/956013  

Read More »

Posted in SQL Server, Troubleshooting

Run DBCC CHECKDB to Check a SQL Server Database

August 6, 2015
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Run DBCC CHECKDB to Check a SQL Server Database

Classic way to check the database is alright. DBCC CHECKDB(‘DatabaseName’) WITH NO_INFOMSGS, ALL_ERRORMSGS

Read More »

Posted in SQL Server, Troubleshooting

Fix SQL Server Error 1222: Lock Request Time Out

July 15, 2015
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Fix SQL Server Error 1222: Lock Request Time Out

In the SQL Server Management Studio, to find out details of the active transaction, execute following command DBCC opentran() You will get the detail of the active transaction, then from the SPID of the active transaction. For example, if SPID is 69 then execute the command as sp_who2 69 sp_lock 69 Now , you can…

Read More »

Posted in SQL Server, Troubleshooting

SQL Agent Job Schedules in Plain English (T-SQL)

July 1, 2015
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: SQL Agent Job Schedules in Plain English (T-SQL)

SELECT SJ.name as job_name , SJ.enabled as is_job_enabled , SS.enabled as is_schedule_enabled /*, ISNULL(SJ.description, ”) as job_desc*/ , SS.name as schedule_name , CASE freq_type WHEN 1 THEN ‘Occurs on ‘ + STUFF(RIGHT(active_start_date, 4), 3,0, ‘/’) + ‘/’ + LEFT(active_start_date, 4) + ‘ at ‘ + REPLACE( RIGHT(CONVERT(varchar(30), CAST(convert(varchar(8), STUFF(STUFF(RIGHT(‘000000’ + CAST(active_start_time as varchar(10)), 6), 3,…

Read More »

Posted in SQL Server, Troubleshooting

Tail-Log Backup in SQL Server: When and How

June 11, 2015
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Tail-Log Backup in SQL Server: When and How

A tail-log backup captures the log records that have not been backed up yet, so a restore loses nothing. Take one before restoring over a database, or after a failure if the log file can still be read. The database must be in FULL or BULK_LOGGED recovery. Tested on SQL Server 2017 and 2025. In…

Read More »

Posted in SQL Server, Troubleshooting

Types of Replication

May 19, 2015
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Types of Replication

Types of Replication Microsoft SQL Server provides the following types of replication for use in distributed applications: Transactional replication. For more information, see Transactional Replication. Merge replication. For more information, see Merge Replication. Snapshot replication. For more information, see Snapshot Replication.

Read More »

Posted in SQL Server, Troubleshooting

Blocking, Timeouts and Deadlocks

April 7, 2015
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Blocking, Timeouts and Deadlocks

These three issues are all related, yet very different. When we deal with reports of problems, it’s essential to clearly identify what is actually happening. Sometimes, we need clarification by asking about the symptoms, instead of accepting what the user says without delving any deeper. The root cause of a problem may not even be…

Read More »

Posted in SQL Server, Troubleshooting

DBCC commands

January 13, 2015
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: DBCC commands

The DBCC commands a DBA still uses on SQL Server 2016 to 2022, grouped by job, with the old ones that have gone or been replaced at the end. Examples tested on SQL Server 2017 and 2025. Checking for corruption DBCC CHECKDB Checks the allocation, structure and logical integrity of every object in a database….

Read More »

Posted in SQL Server, Troubleshooting

SQL Server Database Sizes, Recovery Model and State (T-SQL)

October 10, 2014
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: SQL Server Database Sizes, Recovery Model and State (T-SQL)

Data, log and total size of each user database in MB, with recovery model, compatibility level and state. Uses the file type rather than the .mdf/.ldf name, so extra .ndf files are counted. Works on SQL Server 2016 to 2022 and later. — Data, log and total size per user database in MB (SQL Server…

Read More »

Posted in SQL Server, Troubleshooting

List SQL Server Replication Articles by Publication

September 10, 2014
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: List SQL Server Replication Articles by Publication

SELECT P.[publication] AS [Publication Name] ,A.[publisher_db] AS [Database Name] ,A.[article] AS [Article Name] ,A.[source_owner] AS [Schema] ,A.[source_object] AS [Table] FROM [distribution].[dbo].[MSarticles] AS A INNER JOIN [distribution].[dbo].[MSpublications] AS P ON (A.[publication_id] = P.[publication_id]) ORDER BY P.[publication], A.[article];

Read More »

Posted in SQL Server, Troubleshooting

Recent SQL Agent Job Results on a Server (T-SQL)

August 10, 2014
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Recent SQL Agent Job Results on a Server (T-SQL)

SELECT @@SERVERNAME AS server_name, sjs.last_run_outcome,sj.enabled, sj.name, sjs.step_id, sjs.step_name, sjs.database_name, CAST(CAST(sjs.last_run_date AS varchar(10)) AS datetime) AS failed_date FROM msdb.dbo.sysjobsteps AS sjs INNER JOIN msdb.dbo.sysjobs AS sj ON sjs.job_id = sj.job_id WHERE (sjs.last_run_date <> 0) AND (CAST(CAST(sjs.last_run_date AS varchar(10)) AS datetime) > GETDATE() – 2) ORDER BY sj.name

Read More »

Posted in SQL Server, Troubleshooting

Check SQL Server Backup and Restore Progress (T-SQL)

July 10, 2014
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Check SQL Server Backup and Restore Progress (T-SQL)

SELECT r.session_id, r.command, CONVERT(NUMERIC(6,2),r.percent_complete)AS [Percent Complete], CONVERT(VARCHAR(20),DATEADD(ms,r.estimated_completion_time,GetDate()),20) AS [ETA Completion Time], CONVERT(NUMERIC(10,2),r.total_elapsed_time/1000.0/60.0) AS [Elapsed Min], CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0) AS [ETA Min], CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0/60.0) AS [ETA Hours], CONVERT(VARCHAR(1000),(SELECT SUBSTRING(text,r.statement_start_offset/2, CASE WHEN r.statement_end_offset = -1 THEN 1000 ELSE (r.statement_end_offset-r.statement_start_offset)/2 END) FROM sys.dm_exec_sql_text(sql_handle))) AS [SQL Command] FROM sys.dm_exec_requests AS r WHERE r.command IN (‘RESTORE DATABASE’,’BACKUP DATABASE’)

Read More »

Posted in SQL Server, Troubleshooting

Find the Replication Publication and Subscriber for a Table

April 19, 2014
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Find the Replication Publication and Subscriber for a Table

select article, * from dbo.MSreplication_objects where article like ‘Table_name’ select sp.name, ss.srvname, sa.name from sysarticles sa join syssubscriptions ss on ss.artid = sa.artid join syspublications sp on sa.pubid = sp.pubid where sa.name like ‘table_name’

Read More »

Posted in SQL Server, Troubleshooting

Find Who Dropped a SQL Server Database (Extended Events)

February 15, 2014
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Find Who Dropped a SQL Server Database (Extended Events)

USE master; GO — Create the Event Session IF EXISTS(SELECT * FROM sys.server_event_sessions WHERE name=’DBDeletedCreated’) DROP EVENT SESSION DBDeletedCreated ON SERVER; GO CREATE EVENT SESSION DBDeletedCreated ON SERVER ADD EVENT sqlserver.object_created ( SET collect_database_name = (1) ACTION(sqlserver.nt_username,sqlserver.session_id,sqlserver.client_hostname,sqlserver.client_app_name,sqlserver.sql_text) WHERE object_type = ‘DATABASE’ ), ADD EVENT sqlserver.object_deleted( SET collect_database_name = (1) ACTION(sqlserver.nt_username,sqlserver.session_id,sqlserver.client_hostname,sqlserver.client_app_name,sqlserver.sql_text) WHERE object_type = ‘DATABASE’ )…

Read More »

Posted in SQL Server, Troubleshooting

Fix SQL Server Error 3707 with Emergency Mode and DBCC CHECKDB

January 19, 2013
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: Fix SQL Server Error 3707 with Emergency Mode and DBCC CHECKDB

How to Fix SQL Server Database Error 3707? — 1. ALTER Database leads SET Emergency; GO — 2. ALTER Database leads Set Single_User GO — 3. DBCC CHECKDB (leads, REPAIR_ALLOW_DATA_LOSS) With ALL_ERRORMSGS; GO — 4. ALTER Database leads set multi_user GO

Read More »

Posted in SQL Server, Troubleshooting

DBCC SHRINKDATABASE with TRUNCATEONLY

May 28, 2012
| No Comments
| SQL Server, Troubleshooting
SQL Server Troubleshooting: DBCC SHRINKDATABASE with TRUNCATEONLY

DBCC SHRINKDATABASE (N’Leads’, 0,TRUNCATEONLY)

Read More »

Posted in SQL Server, Troubleshooting

SQL Server DBA Handbook

Setup, backup and high availability (37)
  • Backing Up and Restoring a Database
  • Restoring a Full Database Backup (SSMS)
  • Restoring a Database to a New Location
  • Backup and Restore with T-SQL
  • Disaster Recovery Planning
  • Basic vs Advanced High Availability
  • Adding a Database to an Availability Group
  • Suspending and Resuming Data Movement
  • Availability Group Health Troubleshooting
  • Quorum Failure
  • Log Shipping
  • Database Mail Setup and Troubleshooting
  • Moving TempDB
  • Database Snapshots
  • Server Build Checklist
  • Encryption
  • TDE: Backing Up the Certificate
  • Data Obfuscation and Masking
  • SQL Server Audit
  • FILESTREAM
  • Orphaned SQL Logins
  • Replicating SQL Server Logins with Their SIDs
  • Login Failures (Error 18456)
  • Random Password Generator
  • Generating the SPNs (Kerberos)
  • SQL Server Replication: Setup, Types and Pitfalls
  • Adding an Article to a Publication
  • Enabling Change Tracking: Good and Bad Points
  • Migrating a Reporting Services Installation (Native Mode)
  • Upgrading SSRS 2005 to 2012 (Quick and Dirty)
  • Azure SQL Options
  • Migrating SQL Server to Azure
  • Building an Availability Group
  • Failover Cluster Instances and Distributed Availability Groups
  • Backup to URL and Backup Encryption
  • PowerShell and dbatools
  • SQL Server Trace Flags
Performance (16)
  • Database Performance Tuning and Index Strategy
  • Data Compression
  • Forwarded Records
  • NUMA
  • Common Memory Issues
  • Average Write Performance
  • Stress Testing the I/O Subsystem with SQLIO
  • When the SQL Server Cache Needs to Be Cleared
  • Parameter Sniffing
  • Table Partitioning
  • Resource Governor
  • What Happens During a Data Change: Buffer Pool, Write-Ahead Log and Durability
  • Measuring Query Performance and Taking a Baseline
  • Reading Execution Plans
  • Plan Caching and Parameterization
  • Statistics Problem or Caching Problem?
Troubleshooting (21)
  • Database Suspect, Recovery Pending or Stuck Recovering
  • Shrinking Databases
  • Transaction Log Full
  • Data File Full and Disk Space (Error 1105)
  • Shrinking Transaction Logs
  • Stopping a Running Job in Job Activity Monitor
  • Failed SQL Agent Job Triage
  • Single-User Mode
  • Tempdb Full or Contention
  • Repairing the WMI Provider (mofcomp)
  • SQL Server Referencing the Wrong Disk Drives
  • Performance Troubleshooting Queries
  • High CPU Troubleshooting
  • SQL Locks
  • SQL Server Error Numbers
  • Monitoring Deadlocks
  • Sleeping Processes
  • DMVs and Session Monitoring
  • Collecting Data with Performance Monitor
  • Collecting a Trace with SQL Profiler
  • Schema Locks and Online Index Maintenance
T-SQL (17)
  • SQL Best Practices
  • T-SQL Coding Conventions and Programming Guidelines
  • Common Table Expressions (CTEs)
  • CROSS APPLY and OUTER APPLY
  • Exporting Data to a File
  • SET IDENTITY_INSERT
  • OPENQUERY with Linked Servers
  • Service Broker in SQL Server
  • Enabling and Resetting Service Broker
  • Change Data Capture (CDC)
  • Extended Events
  • Temporal Tables
  • DDL and DML Audit Triggers
  • Transaction Modes: Autocommit, Explicit and Implicit
  • Error Handling in Transactions: TRY/CATCH, @@TRANCOUNT and XACT_STATE()
  • Read Consistency: Read Committed, RCSI and Snapshot Isolation
  • T-SQL Performance Anti-Patterns

Question of the Day

Setup, backup and high availability (5)
  • Encrypting SQL Server Connections
  • SQL Server Certificate Expiry
  • Moving the SQL Server Error Log
  • Backing Up the Database Master Key
  • Fixed Server Roles in SQL Server
Performance (3)
  • Query Store Capture Mode
  • Rebuilding All Indexes on a Table
  • Disabled Indexes in SQL Server
Troubleshooting (3)
  • Running Scripts with the sqlcmd Utility
  • SQL Server Audit Failures
  • Starting SQL Server with Minimal Configuration
T-SQL (24)
  • Converting Money in T-SQL
  • RANK, DENSE_RANK and ROW_NUMBER
  • Finding Special Characters with PATINDEX
  • COUNT(*) vs COUNT(1) in SQL Server
  • The T-SQL FORMAT Function
  • The Table Value Constructor in SQL Server
  • CREATE PROCEDURE in SQL Server
  • The T-SQL AVG Function
  • @@SERVICENAME and the SQL Server Service Name
  • The SQL Server bit Data Type
  • ALTER SCHEMA TRANSFER
  • The BIT_COUNT Function
  • The STRING_ESCAPE Function
  • The T-SQL BETWEEN Operator
  • The T-SQL SQUARE Function
  • Using a Column Alias in ORDER BY
  • The T-SQL SIGN Function
  • T-SQL Reserved Keywords
  • Adding a Column with a DEFAULT
  • Trailing Spaces in SQL Server
  • SQL Server Regex Functions
  • Aggregates on Empty Sets in T-SQL
  • The SQL Server Vector Data Type
  • The T-SQL CHOOSE Function

All Question of the Day posts (35)

Categories

Sidebar

  • Handbook, news and patches (121)
  • Regain sysadmin access (1)
  • Kill SQL processes (1)
  • Configure MSDB (13)
  • TempDB in use (1)
  • Connected to SQL (1)
  • Move backups (2)
  • VLF details (1)
  • Config Manager error (1)
  • Fill factor (1)
  • Missing indexes (1)
  • Number of cores (1)
  • DBCC CHECKDB (1)
  • Wait times (7)
  • Tail-log backup (1)
  • STUFF function (6)
  • Blocking and deadlocks (2)
  • Locking hints (2)
  • Errors 823, 824, 825 (1)
  • DBCC commands (1)
  • Transaction counts (1)
  • Database details (1)
  • Replication (1)
  • Find jobs (1)
  • Backup progress (1)
  • Pivot table (1)
  • Replication objects (1)
  • Tables with no PK (1)
  • Who dropped the database (1)
  • last_value (1)
  • Parse XML (1)
  • Search a string (1)
  • DATETIME difference (1)
  • Error 3707 (1)
  • SHRINKDATABASE (1)
  • Express backup (1)
  • Enable xp_cmdshell (1)
  • Output a file (1)
  • Start of the month (1)

RSS feed: Clive Roberts Clive Roberts

  • RANK, DENSE_RANK and ROW_NUMBER
    Applies to SQL Server 2019, 2022 and 2025. RANK vs DENSE_RANK is one of those choices that looks cosmetic until a report goes out with the wrong number of rows on it. Both number rows in order and both give tied rows the same number. The difference is what happens to the number after a... […]

Recent Posts

  • Converting Money in T-SQL
  • Maintenance Scripts: Ola Hallengren’s Maintenance Solution 20261129_113033
  • RANK, DENSE_RANK and ROW_NUMBER
  • News: [Video] Office Hours: Reflecting on Microsoft Ignite from Cabo
  • Encrypting SQL Server Connections
  • News: Microsoft’s AI Skills Repo Has a Lot of Potential.
  • Running Scripts with the sqlcmd Utility
  • News: What to Do When the SQL Server Keeps Crashing
  • Finding Special Characters with PATINDEX
  • SQL Server Installs Tested Before and After with dbatools and Pester
  • COUNT(*) vs COUNT(1) in SQL Server
  • The T-SQL FORMAT Function
  • News: SQL Server 2022 SQLskills Blackbelt Credly badge now available
  • The Table Value Constructor in SQL Server
  • CREATE PROCEDURE in SQL Server
  • News: [Video] Office Hours: Back from the PASS Summit
  • The T-SQL AVG Function
  • News: Black Friday Sale – Blackbelt for $399!
  • Capacity Report: When Each Drive Will Be Full
  • SQL Server Security Report: Who Has sysadmin, and What Changed
  • SQL Server Patch Report: Every Instance Against Its Target Build
  • Windows Patch Report: Did This Month’s Updates Land?
  • Integrity Check Report: Proving CHECKDB Actually Ran
  • News: Modernize your apps with Azure SQL Database Hyperscale
  • News: Would Open-Sourcing Microsoft SQL Server Actually Fix Anything?
  • SQL Server Certificate Expiry
  • News: Make Your Nightly ETL Faster with TABLOCKX
  • @@SERVICENAME and the SQL Server Service Name
  • Moving the SQL Server Error Log
  • News: FGCB_ADD_REMOVE Latch Investigation Demo
  • Who Is Really a Sysadmin? Expanding AD Groups in SQL Server with xp_logininfo
  • SSIS Error Report: Finding the Package That Failed
  • Backup Report: Is Every Database Backed Up?
  • Database Inventory Report
  • SQL Server Inventory Report
  • Disk Space Alerts for SQL Server
  • Server Availability Report: Ping and Response Time
  • SQL Server Licensing Report
  • Query Store Capture Mode
  • SQL Server Audit Failures
  • News: [Video] Office Hours in the Backyard
  • The SQL Server bit Data Type
  • News: What Students are Saying About My Latest Classes
  • ALTER SCHEMA TRANSFER
  • News: How to Set Background Images & Movies in SSMS v22
  • Starting SQL Server with Minimal Configuration
  • News: Are Blogs Still Relevant? #tsql2sday
  • Backing Up the Database Master Key
  • News: Free Webcast: My Favorite Query Hints
  • News: Announcing Microsoft Database Hub: An Incredible Pace of Innovation
  • The BIT_COUNT Function
  • Rebuilding All Indexes on a Table
  • The STRING_ESCAPE Function
  • The T-SQL BETWEEN Operator
  • News: [Video] Office Hours: An AI Agent Stops In to Ask a Question
  • The T-SQL SQUARE Function
  • News: The Top 10 SQL Server Wait Types, Worldwide
  • Using a Column Alias in ORDER BY
  • Disabled Indexes in SQL Server
  • News: Who’s Hiring Database People? November 2026 Edition
  • The T-SQL SIGN Function
  • News: My Black Friday Sale on Training Classes is Open Now!
  • T-SQL Reserved Keywords
  • Patch: SQL Server 2022 CU28 (build 16.0.4325.4)
  • Patch: SQL Server 2025 CU11 (build 17.0.5065.9)
  • Patch: SQL Server 2017 CU31 + GDR (build 14.0.3570.2)
  • Patch: SQL Server 2017 GDR (build 14.0.2150.2)
  • Patch: SQL Server 2019 CU32 + GDR (build 15.0.4510.2)
  • Patch: SQL Server 2019 GDR (build 15.0.2210.4)
  • Patch: SQL Server 2022 CU27 + GDR (build 16.0.4315.2)
  • Patch: SQL Server 2022 GDR (build 16.0.1220.3)
  • Patch: SQL Server 2025 CU10 + GDR (build 17.0.5045.3)
  • Patch: SQL Server 2025 GDR (build 17.0.1155.3)
  • Adding a Column with a DEFAULT
  • News: [Video] Office Hours: 4 Great Questions Off Canada
  • Trailing Spaces in SQL Server
  • News: Meet Hugo Kornelis, Execution Plan Expert.
  • SQL Server Regex Functions
  • News: Why You Don’t Get Parallelism When You Ask for The Whole Table
  • Fixed Server Roles in SQL Server
  • News: New Stuff in the Mastering Server Tuning Class
  • Aggregates on Empty Sets in T-SQL
  • News: This Friday’s the Deadline for My Next Live Class Rotation.
  • The SQL Server Vector Data Type
  • The T-SQL CHOOSE Function
  • News: [Video] Talking Pronouns in Alaska
  • News: Why’s This Query So Slow in Prod? Check sp_BlitzPlanCompare.
  • News: AI Stories and Thoughts
  • News: I’m Probably Not Supposed To Show You Microsoft’s Auto-Indexing Tool.
  • SQL Server Trace Flags
  • Statistics Problem or Caching Problem?
  • Plan Caching and Parameterization
  • T-SQL Performance Anti-Patterns
  • Reading Execution Plans
  • Measuring Query Performance and Taking a Baseline
  • News: Thoughts on AI After My Panel Discussion
  • Read Consistency: Read Committed, RCSI and Snapshot Isolation
  • Schema Locks and Online Index Maintenance
  • What Happens During a Data Change: Buffer Pool, Write-Ahead Log and Durability
  • Error Handling in Transactions: TRY/CATCH, @@TRANCOUNT and XACT_STATE()
  • Transaction Modes: Auto commit, Explicit and Implicit
  • PowerShell and dbatools
  • Resource Governor
  • Table Partitioning
  • Backup to URL and Backup Encryption
  • Failover Cluster Instances and Distributed Availability Groups
  • Building an Availability Group
  • Parameter Sniffing
  • DDL and DML Audit Triggers
  • Temporal Tables
  • Extended Events
  • Change Data Capture (CDC)
  • Migrating SQL Server to Azure
  • Azure SQL Options
  • News: [Video] Office Hours on the Last Alaskan Cruise of the Season
  • Upgrading SSRS 2005 to 2012 (Quick and Dirty)
  • Migrating a Reporting Services Installation (Native Mode)
  • Health Check 00: is this SQL Server running well?
  • Health Check 01: server overview
  • Health Check 02: databases
  • Health Check 03: backups
  • Health Check 04: disks and files
  • Health Check 05: SQL Agent jobs
  • Health Check 06: wait statistics
  • Health Check 07: activity and blocking
  • Health Check 08: error log
  • Health Check 09: integrity checks
  • Health Check 10: memory and CPU
  • Health Check 11: tempdb
  • Health Check 12: high availability
  • Performance 01: top queries
  • Performance 02: Query Store regressions
  • Performance 03: missing indexes
  • Performance 04: unused indexes
  • Performance 05: statistics age
  • Performance 06: index fragmentation
  • Performance 07: cardinality estimate skew
  • Performance 08: filtered statistics candidates
  • Performance 09: duplicate and overlapping indexes
  • Performance 10: statistics health
  • Performance 11: cardinality estimator audit
  • Performance 12: implicit conversions
  • Enabling Change Tracking: Good and Bad Points
  • Adding an Article to a Publication
  • SQL Server Replication: Setup, Types and Pitfalls
  • Enabling and Resetting Service Broker
  • Service Broker in SQL Server
  • OPENQUERY with Linked Servers
  • News: Breaking News: Hold Off on SSMS 22.11.0
  • News: Fact-Checking Microsoft’s “PostgreSQL to SQL Field Notes: Connections”
  • SET IDENTITY_INSERT
  • Exporting Data to a File
  • CROSS APPLY and OUTER APPLY
  • Common Table Expressions (CTEs)
  • T-SQL Coding Conventions and Programming Guidelines
  • SQL Best Practices
  • Generating the SPNs (Kerberos)
  • Random Password Generator
  • News: Free Webcast: How to Think Like the SQL Server & Postgres Engines
  • Login Failures (Error 18456)
  • Replicating SQL Server Logins with Their SIDs
  • Orphaned SQL Logins
  • FILESTREAM
  • SQL Server Audit
  • Patch: SQL Server 2017 CU31 + GDR (build 14.0.3560.2)
  • Patch: SQL Server 2017 GDR (build 14.0.2140.2)
  • Patch: SQL Server 2019 CU32 + GDR (build 15.0.4500.2)
  • Patch: SQL Server 2019 GDR (build 15.0.2200.2)
  • Patch: SQL Server 2022 CU27 + GDR (build 16.0.4305.5)
  • Patch: SQL Server 2022 GDR (build 16.0.1210.3)
  • Patch: SQL Server 2025 CU9 + GDR (build 17.0.5015.4)
  • Patch: SQL Server 2025 GDR (build 17.0.1145.4)
  • Data Obfuscation and Masking
  • TDE: Backing Up the Certificate
  • Encryption
  • Collecting a Trace with SQL Profiler
  • Collecting Data with Performance Monitor
  • DMVs and Session Monitoring
  • Sleeping Processes
  • Monitoring Deadlocks
  • SQL Server Error Numbers
  • SQL Locks
  • High CPU Troubleshooting
  • Performance Troubleshooting Queries
  • When the SQL Server Cache Needs to Be Cleared
  • Stress Testing the I/O Subsystem with SQLIO
  • Average Write Performance
  • Common Memory Issues
  • NUMA
  • Forwarded Records
  • Data Compression
  • Database Performance Tuning and Index Strategy
  • Server Build Checklist
  • SQL Server Referencing the Wrong Disk Drives
  • Repairing the WMI Provider (mofcomp)
  • Database Snapshots
  • Tempdb Full or Contention
  • Moving TempDB
  • Single-User Mode
  • Database Mail Setup and Troubleshooting
  • Setup
  • Performance
  • Health Check
  • Troubleshooting
  • T-SQL
  • Patches
  • News
  • Audit
  • Projects

Precious Lite 2025 | All Rights Reserved. Precious Lite theme by Flythemes