SQL DBA Blog: Home

  • DBA Scripts: Get Migration Risk Assessment

    Part of the DBA-Tools Project. Every migration has a list of things that will cause a problem if nobody checks for them first: a database in an Availability Group that needs coordinated removal, a linked server dependency that won’t resolve on the target, an owner SID that doesn’t exist anywhere anymore. Discovering these mid-cutover, instead…

    read more

  • DBA Scripts: Get Unused Indexes

    Part of the DBA-Tools Project. Every non-clustered index has to be maintained by SQL Server on every INSERT, UPDATE, and DELETE against the table. A table with 12 non-clustered indexes means 12 index updates for every row changed. Some of those indexes earn their keep by serving real queries. Others haven’t been read by a…

    read more

  • DBA Scripts: Get Deadlock Summary

    Part of the DBA-Tools Project. A deadlock is SQL Server’s way of resolving a situation it can’t otherwise escape: two transactions each holding a lock the other one needs, waiting on each other forever unless something intervenes. SQL Server intervenes automatically, picks one transaction as the victim, kills it, and lets the other proceed. The…

    read more

  • DBA Scripts: Get Replication Status

    Part of the DBA-Tools Project. Transactional replication runs quietly in the background for years without incident, right up until a subscriber falls behind or a publication stops distributing changes, and by then the business impact (a reporting database showing stale data, a downstream system missing updates) has usually already been noticed by someone other than…

    read more

  • DBA Scripts: Extended Events Tracing

    Part of the DBA-Tools Project, in the Performance and Troubleshooting area. Ask most DBAs “what’s actually connecting to this server” or “is this database still in use” and you’ll get an opinion, not an answer. SQL Server doesn’t track any of this for you by default, no login history worth trusting, no record of which…

    read more

  • DBA Scripts: Get Blocking Chains

    Part of the DBA-Tools Project. A single blocked session is usually easy to spot. The harder case is a chain: session C is waiting on session B, which is itself waiting on session A, which is sitting idle holding a lock from a transaction nobody remembers is still open. Killing C’s session does nothing, C…

    read more

  • DBA Scripts: Get Orphaned Users

    Part of the DBA-Tools Project. An orphaned user is a database user whose SID no longer matches any server login, usually left behind after a database restore or attach on a different server, a migration, or a login that was dropped without cleaning up the database users mapped to it. The user still exists in…

    read more

  • DBA Scripts: Get Database Backup History

    Part of the DBA-Tools Project. Most backup checks answer one question: what’s the latest backup. That’s the right question most of the time, but it hides everything that happened before it. A backup job that ran reliably for a year and then quietly changed behaviour three weeks ago still passes a “latest backup is recent”…

    read more

  • When Shrinking Temp DB Just Won’t Shrink

    This is broken. You run DBCC SHRINKFILE on the Temp DB data files, maybe throw in a CHECKPOINT for good measure, and nothing moves. The files sit there stubbornly taking up space you need back. I am not in the habit of shrinking databases. It fragments files and usually just creates more work later. But…

    read more

  • DBA Scripts: Get Recent Error Log Entries

    Part of the DBA-Tools Project. The SQL Server error log records almost everything worth knowing about an instance’s recent health, and almost nobody reads it until they’re already troubleshooting something. It’s not that the information isn’t there, it’s that xp_readerrorlog returns thousands of lines dominated by routine noise, every successful backup, every log backup, every…

    read more