<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SQL Server Administration on SQL Server Scripts</title><link>https://www.sqlserver70.com/series/sql-server-administration/</link><description>Recent content in SQL Server Administration on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Sat, 23 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/series/sql-server-administration/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Server Object Dependencies Report: Find All References</title><link>https://www.sqlserver70.com/post/sql-server-object-dependencies-script/</link><pubDate>Sat, 23 May 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-object-dependencies-script/</guid><description>
&lt;p&gt;Before renaming a column, retiring a view, or dropping a stored procedure, every DBA needs the answer to one question: what else depends on this object? This T-SQL script reads &lt;code&gt;sys.sql_expression_dependencies&lt;/code&gt; and reports every referencing-and-referenced pair in the current database, with optional filtering to a single object name — the safe-refactoring impact analysis report.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;SQL Server tracks expression-level dependencies between user objects in the catalog view &lt;code&gt;sys.sql_expression_dependencies&lt;/code&gt;. Every reference from a stored procedure, function, view, trigger, default, computed column, or check constraint to another object — table, view, function, procedure, type, or column — produces a row. The view supersedes the legacy &lt;code&gt;sys.sql_dependencies&lt;/code&gt; view (deprecated in SQL Server 2008) and the older &lt;code&gt;sp_depends&lt;/code&gt; stored procedure (which has always been unreliable for cross-database and late-bound references). Modern dependency tracking is metadata-only, schema-bound-aware, and accurate across cross-database name resolutions.&lt;/p&gt;</description></item><item><title>SQL Server Max Server Memory Calculator Script</title><link>https://www.sqlserver70.com/post/sql-server-max-server-memory-calculator-script/</link><pubDate>Sat, 16 May 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-max-server-memory-calculator-script/</guid><description>
&lt;p&gt;Every SQL Server installation ships with &lt;code&gt;max server memory&lt;/code&gt; set to its default value of 2,147,483,647 MB — effectively unlimited — which allows the Buffer Pool to consume all available RAM and starve the operating system of the memory it needs for network stack, disk I/O, and other critical processes. This script reads total physical RAM from &lt;code&gt;sys.dm_os_sys_info&lt;/code&gt;, applies Jonathan Kehayias's widely-adopted OS reservation formula, and compares the recommended cap to the current &lt;code&gt;sp_configure&lt;/code&gt; setting so DBAs can see at a glance whether action is needed.&lt;/p&gt;</description></item><item><title>SQL Server MAXDOP Recommendation Script</title><link>https://www.sqlserver70.com/post/sql-server-maxdop-recommendation-script/</link><pubDate>Fri, 17 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-maxdop-recommendation-script/</guid><description>
&lt;p&gt;MAXDOP (max degree of parallelism) controls how many CPU threads SQL Server can use for a single parallel query. The default value of 0 allows SQL Server to use all available processors, which can cause large parallel queries to monopolise the server. This script reads the CPU topology from system DMVs and calculates Microsoft's recommended MAXDOP value for your instance.&lt;/p&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;p&gt;Setting MAXDOP incorrectly is one of the most common SQL Server configuration gaps. With MAXDOP 0 (unlimited), a single parallel query can consume every logical processor on the server, blocking other queries from getting CPU time. Setting MAXDOP too low, such as 1, disables parallelism entirely and slows down queries that benefit from parallel execution.&lt;/p&gt;</description></item><item><title>SQL Server Agent Job Failure History Report</title><link>https://www.sqlserver70.com/post/sql-server-agent-job-failure-history-report/</link><pubDate>Sat, 11 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-agent-job-failure-history-report/</guid><description>
&lt;h2 id="report-sql-server-agent-job-status-and-failure-history"&gt;Report SQL Server Agent Job Status and Failure History&lt;/h2&gt;
&lt;p&gt;This script queries the SQL Server Agent job history stored in msdb to produce a detailed report of each job's most recent run status, failure and success counts over the last 60 days, total lifetime run counts, and job step information including subsystem type and proxy name.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;SQL Server Agent jobs automate the critical work of database backups, index maintenance, integrity checks, ETL loads, and more. When a job fails, the impact can range from a missed backup to a halted data pipeline. Knowing which jobs failed, how recently they failed, and whether failures are isolated events or a recurring pattern is essential for any DBA. This script, written by Jason Brimhall and published in the ktaranov/sqlserver-kit community repository, uses a series of common table expressions to build a rich job history report. It shows the most recent outcome for each job status type, counts failures and successes within the last 60 days relative to the latest run, and includes job step details. To report only failures, uncomment one line. Run this script in the context of the &lt;code&gt;msdb&lt;/code&gt; database.&lt;/p&gt;</description></item><item><title>SQL Server Kill Sessions: Filtered SPID Management</title><link>https://www.sqlserver70.com/post/sql-server-kill-all-connections-to-a-database/</link><pubDate>Sat, 11 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-kill-all-connections-to-a-database/</guid><description>
&lt;h2 id="kill-sql-server-sessions-with-targeted-filters-using-kill-and-dm_exec_sessions"&gt;Kill SQL Server Sessions with Targeted Filters Using KILL and dm_exec_sessions&lt;/h2&gt;
&lt;p&gt;This article covers a practical T-SQL script that kills one or more SQL Server sessions (SPIDs) while giving you precise control over which sessions are targeted. The script uses &lt;code&gt;sys.dm_exec_sessions&lt;/code&gt; to query active sessions and a cursor to issue &lt;code&gt;KILL&lt;/code&gt; commands only against sessions that match your chosen filters.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;When you need to disconnect users from a SQL Server database — whether before taking it offline, restoring it, or clearing stuck sessions — the built-in &lt;code&gt;KILL&lt;/code&gt; command works on one session at a time. Writing a loop to kill many sessions adds complexity. This script wraps that logic into a reusable tool with a safety switch and seven filter parameters so you can scope kills as broadly or narrowly as needed.&lt;/p&gt;</description></item><item><title>SQL Server Search Stored Procedure and View Text</title><link>https://www.sqlserver70.com/post/sql-server-search-stored-procedure-view-text/</link><pubDate>Thu, 09 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-search-stored-procedure-view-text/</guid><description>
&lt;h2 id="search-stored-procedure-and-view-definitions-in-sql-server"&gt;Search Stored Procedure and View Definitions in SQL Server&lt;/h2&gt;
&lt;p&gt;This script searches the text of stored procedures, views, functions, and triggers in the current database using &lt;code&gt;sys.sql_modules&lt;/code&gt;, returning any programmable object whose name or definition contains a given keyword.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;Finding which stored procedures, views, or functions reference a specific table, column, or keyword is a routine DBA and developer task. It comes up when renaming a column, tracking down where a piece of business logic lives, auditing who calls a particular table, or investigating the impact of a schema change. SQL Server stores the source definition of every programmable object in &lt;code&gt;sys.sql_modules&lt;/code&gt;, making it straightforward to search across all object types in a single query. This script, adapted from the sqlserver-kit community collection by Ed Pollack and Konstantin Taranov, queries &lt;code&gt;sys.sql_modules&lt;/code&gt; joined to &lt;code&gt;sys.objects&lt;/code&gt; to search both object names and their full definitions, returning results with the object type, schema, and full source text.&lt;/p&gt;</description></item><item><title>SQL Server Error Log Search Script: xp_readerrorlog</title><link>https://www.sqlserver70.com/post/sql-server-error-log-search-script-xp-readerrorlog/</link><pubDate>Wed, 08 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-error-log-search-script-xp-readerrorlog/</guid><description>
&lt;h2 id="search-the-sql-server-error-log-with-xp_readerrorlog"&gt;Search the SQL Server Error Log with xp_readerrorlog&lt;/h2&gt;
&lt;p&gt;This script reads and filters the SQL Server error log using &lt;code&gt;xp_readerrorlog&lt;/code&gt; and &lt;code&gt;sys.sp_readerrorlog&lt;/code&gt;, supporting keyword search, date range filtering, and access to archived log files — all from T-SQL without touching the file system.&lt;/p&gt;
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;The SQL Server error log records startup events, login failures, database state changes, backup completions, DBCC output, and any errors raised by the engine. When something goes wrong — a database goes suspect, a backup fails, or a login is repeatedly denied — the error log is the first place to look. SQL Server provides two built-in mechanisms for reading the log from T-SQL: the undocumented extended stored procedure &lt;code&gt;xp_readerrorlog&lt;/code&gt; and its documented wrapper &lt;code&gt;sys.sp_readerrorlog&lt;/code&gt;. Both support keyword filtering and date ranges, making them far more useful than opening the log file in SSMS's Log Viewer for scripted or automated diagnostic work. This script, adapted from the Read_errorlog.sql in the sqlserver-kit collection by Konstantin Taranov, demonstrates how to search one or more error log files efficiently from T-SQL.&lt;/p&gt;</description></item><item><title>SQL Server DBCC CHECKIDENT: Bulk Identity Column Analysis</title><link>https://www.sqlserver70.com/post/sql-server-dbcc-checkident-identity-management-script/</link><pubDate>Sun, 03 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-dbcc-checkident-identity-management-script/</guid><description>
&lt;h2 id="sql-server-dbcc-checkident-complete-guide-to-identity-column-management-and-bulk-table-analysis"&gt;SQL Server DBCC CHECKIDENT: Complete Guide to Identity Column Management and Bulk Table Analysis&lt;/h2&gt;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;DBCC CHECKIDENT&lt;/code&gt; command is a critical database administration tool in Microsoft SQL Server designed to manage and monitor identity column values. This article explores a practical implementation that demonstrates both individual table identity checking and automated bulk analysis across all user tables in a database.
&lt;script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1012089347386563"
crossorigin="anonymous"&gt;&lt;/script&gt;
&lt;ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1012089347386563"
data-ad-slot="8593449130"&gt;&lt;/ins&gt;
&lt;script&gt;
(adsbygoogle = window.adsbygoogle || []).push({});
&lt;/script&gt;
&lt;/p&gt;</description></item></channel></rss>