<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on SQL Server Scripts</title><link>https://www.sqlserver70.com/post/</link><description>Recent content in Posts on SQL Server Scripts</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>SQLServer70.com</copyright><lastBuildDate>Sat, 11 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://www.sqlserver70.com/post/index.xml" rel="self" type="application/rss+xml"/><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 Backup Status Report: All Databases</title><link>https://www.sqlserver70.com/post/sql-server-backup-status-report-last-backup-all-databases/</link><pubDate>Fri, 10 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-backup-status-report-last-backup-all-databases/</guid><description>
&lt;h2 id="check-sql-server-backup-age-across-all-databases"&gt;Check SQL Server Backup Age Across All Databases&lt;/h2&gt;
&lt;p&gt;This script queries the SQL Server backup history catalog to report the most recent full, differential, and transaction log backup for every database, including how many hours and minutes ago each backup completed.&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;Database backups are your last line of defense against data loss. Knowing exactly when each database was last backed up — and how old that backup is right now — is a fundamental DBA responsibility. This script, originally written by Tim Ford, joins &lt;code&gt;master.sys.databases&lt;/code&gt; with the msdb backup history tables to produce a single report covering all backup types for all databases. It shows the backup finish time, the physical backup file path, and elapsed time in both hours and minutes, making it straightforward to spot any database that has missed a scheduled backup.&lt;/p&gt;</description></item><item><title>SQL Server Verify Backup Files: RESTORE VERIFYONLY</title><link>https://www.sqlserver70.com/post/sql-server-verify-backup-files-restore-verifyonly/</link><pubDate>Mon, 06 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-verify-backup-files-restore-verifyonly/</guid><description>
&lt;h2 id="verify-sql-server-backup-files-with-restore-verifyonly"&gt;Verify SQL Server Backup Files with RESTORE VERIFYONLY&lt;/h2&gt;
&lt;p&gt;Backup files that cannot be restored are worthless, and many DBAs discover problems only when they attempt an actual restore under pressure. The scripts in this article use &lt;code&gt;RESTORE VERIFYONLY&lt;/code&gt; to confirm that backup files are readable and internally consistent before a real disaster occurs.&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;&lt;code&gt;RESTORE VERIFYONLY&lt;/code&gt; reads a backup file and validates its structure without writing any data to a database. It checks that the backup set is complete, that all volumes are readable, and that header metadata is intact. It does not verify that every data page is logically consistent, but it catches the most common failure modes: truncated files, corrupted headers, and missing media families.&lt;/p&gt;</description></item><item><title>SQL Server Point-in-Time Restore with STOPAT</title><link>https://www.sqlserver70.com/post/sql-server-point-in-time-restore-script-stopat/</link><pubDate>Sun, 05 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-point-in-time-restore-script-stopat/</guid><description>
&lt;h2 id="recover-a-sql-server-database-to-a-specific-point-in-time"&gt;Recover a SQL Server Database to a Specific Point in Time&lt;/h2&gt;
&lt;p&gt;SQL Server's &lt;code&gt;RESTORE LOG ... WITH STOPAT&lt;/code&gt; lets you roll a database back to any exact moment covered by your backup chain. This guide walks through querying backup history in &lt;code&gt;msdb&lt;/code&gt;, executing the restore sequence, and verifying the result.&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;Data loss incidents — accidental deletes, bad deployments, runaway updates — rarely happen at a convenient backup boundary. Point-in-time restore solves this by replaying transaction logs only up to a target timestamp, leaving the database in a consistent state as of that moment.&lt;/p&gt;</description></item><item><title>SQL Server Blocking Detection: Find Blocked Sessions</title><link>https://www.sqlserver70.com/post/sql-server-blocking-detection-find-blocked-sessions/</link><pubDate>Sun, 01 Mar 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-blocking-detection-find-blocked-sessions/</guid><description>
&lt;p&gt;Blocking in SQL Server occurs when one session holds a lock that another session needs, causing the second session to wait. This T-SQL script queries the dynamic management views to show all currently blocked sessions, the blocking session, wait type, wait duration, and the SQL text involved.&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 users report slow queries or application timeouts, blocking is a common cause. SQL Server does not alert you to blocking by default — you must query the DMVs to see what is happening in real time.&lt;/p&gt;</description></item><item><title>SQL Server Missing Indexes Report: dm_db_missing_index</title><link>https://www.sqlserver70.com/post/sql-server-missing-indexes-report-sys-dm-db-missing-index-details/</link><pubDate>Sat, 28 Feb 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-missing-indexes-report-sys-dm-db-missing-index-details/</guid><description>
&lt;p&gt;SQL Server tracks index recommendations automatically as queries execute, storing them in the missing index DMVs. This T-SQL script queries those views to produce a ranked report of missing indexes, ordered by the estimated improvement they would provide, along with a ready-to-run &lt;code&gt;CREATE INDEX&lt;/code&gt; statement for each recommendation.&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;Every time SQL Server executes a query that would benefit from an index that does not exist, it records the recommendation in &lt;code&gt;sys.dm_db_missing_index_details&lt;/code&gt;. Over time these recommendations accumulate and can reveal the highest-impact indexing changes you can make to improve query performance.&lt;/p&gt;</description></item><item><title>SQL Server Wait Statistics Report: dm_os_wait_stats</title><link>https://www.sqlserver70.com/post/sql-server-wait-statistics-report-sys-dm-os-wait-stats/</link><pubDate>Fri, 27 Feb 2026 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-wait-statistics-report-sys-dm-os-wait-stats/</guid><description>
&lt;p&gt;Wait statistics are one of the most reliable ways to identify performance bottlenecks in SQL Server. This T-SQL script queries &lt;code&gt;sys.dm_os_wait_stats&lt;/code&gt;, filters out background and idle wait types that do not indicate real problems, and ranks the remaining waits by their percentage of total wait time.&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;Every time SQL Server cannot immediately process a request — because it is waiting for CPU, disk, memory, locks, or network — it records that wait in &lt;code&gt;sys.dm_os_wait_stats&lt;/code&gt;. Over time this DMV accumulates a comprehensive picture of where SQL Server spends time waiting.&lt;/p&gt;</description></item><item><title>SQL Server Primary Key Discovery Script: sp_pkeys Guide</title><link>https://www.sqlserver70.com/post/sql-server-primary-key-discovery-script/</link><pubDate>Sat, 09 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-primary-key-discovery-script/</guid><description>
&lt;h2 id="sql-server-primary-key-discovery-script-using-sp_pkeys-and-sysobjects"&gt;SQL Server Primary Key Discovery Script Using sp_pkeys and sysobjects&lt;/h2&gt;
&lt;h2 id="purpose"&gt;Purpose&lt;/h2&gt;
&lt;p&gt;This SQL Server script generates dynamic SQL statements that can be executed to discover primary keys across all user tables in a database. It's a powerful administrative tool that helps database administrators quickly identify primary key constraints without manually checking each table individually.
&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;
&lt;h2 id="code-breakdown"&gt;Code Breakdown&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;select &amp;#34;Processing Table &amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#34;go&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39; sp_pkeys &amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;go&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sysobjects&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;U&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;by&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let's break down each component of this query:&lt;/p&gt;</description></item><item><title>SQL Server: Find Tables with Clustered Indexes for Rebuild</title><link>https://www.sqlserver70.com/post/sql-server-query-to-identify-tables-with-clustered-indexes-for-rebuilding/</link><pubDate>Sat, 09 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-query-to-identify-tables-with-clustered-indexes-for-rebuilding/</guid><description>
&lt;h2 id="sql-server-query-to-identify-tables-with-clustered-indexes-for-rebuilding"&gt;SQL Server Query to Identify Tables with Clustered Indexes for Rebuilding&lt;/h2&gt;
&lt;p&gt;Database administrators frequently need to perform maintenance operations on clustered indexes to optimize database performance. This SQL Server query provides a quick and efficient way to identify all user tables that contain clustered indexes, which is typically the first step in a comprehensive index rebuilding strategy.
&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;
&lt;h2 id="the-sql-query"&gt;The SQL Query&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;distinct&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sysobjects&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sysindexes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;U&amp;#39;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;5&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;6&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;by&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="purpose-and-use-case"&gt;Purpose and Use Case&lt;/h2&gt;
&lt;p&gt;This query serves as a foundation script for database maintenance operations, specifically designed to:&lt;/p&gt;</description></item><item><title>SQL Server Object Permissions: Generate GRANT Statements</title><link>https://www.sqlserver70.com/post/sql-server-object-level-permissions-script-generate-grant-statements-for-database-security/</link><pubDate>Fri, 08 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-object-level-permissions-script-generate-grant-statements-for-database-security/</guid><description>
&lt;h2 id="sql-server-object-level-permissions-script-generate-grant-statements-for-database-security"&gt;SQL Server Object-Level Permissions Script: Generate GRANT Statements for Database Security&lt;/h2&gt;
&lt;p&gt;Database security is a critical aspect of SQL Server administration, and managing permissions at the object level can be time-consuming when done manually. This SQL Server script automates the process of generating GRANT statements for all database objects, making it easier for database administrators to apply consistent permissions across their database schema.&lt;/p&gt;
&lt;h2 id="purpose-of-the-script"&gt;Purpose of the Script&lt;/h2&gt;
&lt;p&gt;This SQL Server script is designed to automatically generate GRANT permission statements for all user tables and stored procedures in a database. Instead of manually writing individual GRANT statements for each object, this script queries the system catalog to dynamically create the necessary permission commands for a specific database role called &lt;code&gt;SelectInsertUpdateDeleteExecSP&lt;/code&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;</description></item><item><title>Generate SQL Server Space Usage Commands for All User Tables</title><link>https://www.sqlserver70.com/post/sql-server-generate-space-usage-commands-for-all-tables/</link><pubDate>Thu, 07 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-generate-space-usage-commands-for-all-tables/</guid><description>
&lt;h2 id="generate-sql-server-space-usage-commands-for-all-user-tables"&gt;Generate SQL Server Space Usage Commands for All User Tables&lt;/h2&gt;
&lt;p&gt;Managing database storage is a critical aspect of SQL Server administration. Understanding how much space each table consumes helps database administrators make informed decisions about maintenance, archiving, and performance optimization. This article explores a powerful T-SQL script that automatically generates space usage commands for all user tables in your 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;
&lt;h2 id="the-sql-server-code"&gt;The SQL Server Code&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;sp_spaceused &amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;go&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sysobjects&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;U&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;order&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;by&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;This T-SQL query serves as a time-saving utility for database administrators who need to quickly assess the space usage of all user tables in a SQL Server database. Instead of manually typing &lt;code&gt;sp_spaceused&lt;/code&gt; commands for each table, this script automatically generates the complete set of commands ready for execution.&lt;/p&gt;</description></item><item><title>SQL Server UPDATE STATISTICS and SELECT Dynamic Scripts</title><link>https://www.sqlserver70.com/post/sql-server-dynamic-update-statistics-and-select-scripts/</link><pubDate>Wed, 06 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-dynamic-update-statistics-and-select-scripts/</guid><description>
&lt;h2 id="sql-server-dynamic-update-statistics-and-select-scripts-for-database-maintenance"&gt;SQL Server Dynamic Update Statistics and Select Scripts for Database Maintenance&lt;/h2&gt;
&lt;h2 id="purpose"&gt;Purpose&lt;/h2&gt;
&lt;p&gt;These SQL Server scripts are designed to automatically generate database maintenance commands by dynamically creating UPDATE STATISTICS statements and SELECT queries for all user tables in a database. This approach is particularly useful for database administrators who need to perform bulk operations across multiple tables without manually writing individual commands for each table.
&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><item><title>SQL Server DBCC DBREINDEX with Timing: Index Maintenance</title><link>https://www.sqlserver70.com/post/sql-server-dbcc-dbreindex-script-with-timing-database-maintenance-guide/</link><pubDate>Tue, 05 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-dbcc-dbreindex-script-with-timing-database-maintenance-guide/</guid><description>
&lt;h2 id="sql-server-dbcc-dbreindex-script-with-timing---database-maintenance-guide"&gt;SQL Server DBCC DBREINDEX Script with Timing - Database Maintenance Guide&lt;/h2&gt;
&lt;p&gt;Database maintenance is a critical aspect of SQL Server administration, and index rebuilding plays a vital role in maintaining optimal database performance. This comprehensive guide explores powerful DBCC DBREINDEX scripts that include timing functionality to help database administrators monitor and optimize their maintenance operations.
&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;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;The DBCC DBREINDEX scripts presented here are designed to automate the process of rebuilding indexes on all user tables within a SQL Server database. These scripts generate dynamic SQL commands that can be executed to defragment and reorganize table indexes, ultimately improving query performance and database efficiency.&lt;/p&gt;</description></item><item><title>SQL Server DBCC DBREINDEX Script Generator: DB Maintenance</title><link>https://www.sqlserver70.com/post/sql-server-dbcc-dbreindex-script-generator-for-database-maintenance/</link><pubDate>Mon, 04 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-dbcc-dbreindex-script-generator-for-database-maintenance/</guid><description>
&lt;h2 id="sql-server-dbcc-dbreindex-script-generator-for-database-maintenance"&gt;SQL Server DBCC DBREINDEX Script Generator for Database Maintenance&lt;/h2&gt;
&lt;p&gt;Database maintenance is crucial for optimal SQL Server performance, and one of the most important tasks is maintaining database indexes. The &lt;code&gt;DBCC DBREINDEX&lt;/code&gt; command is a powerful tool for rebuilding indexes, but manually running it on every table can be time-consuming. This article explores automated script generation techniques to streamline your database maintenance workflow.
&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><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><item><title>SQL Server Table Row Count Report: Complete T-SQL Script</title><link>https://www.sqlserver70.com/post/sql-server-database-table-row-count-report-script/</link><pubDate>Sat, 02 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-database-table-row-count-report-script/</guid><description>
&lt;h2 id="sql-server-database-table-row-count-report-script---complete-guide"&gt;SQL Server Database Table Row Count Report Script - Complete Guide&lt;/h2&gt;
&lt;p&gt;Database administrators frequently need to monitor table sizes and row counts across their SQL Server databases. This comprehensive guide explores a powerful T-SQL script that generates detailed table row count reports using cursor-based iteration and system table queries.
&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;
&lt;h2 id="purpose-and-overview"&gt;Purpose and Overview&lt;/h2&gt;
&lt;p&gt;The &amp;quot;Run Space Report&amp;quot; script serves as a database monitoring tool that captures essential table statistics including server name, execution timestamp, database name, table name, and total row counts. This information proves invaluable for capacity planning, performance optimization, and database maintenance activities.&lt;/p&gt;</description></item><item><title>Generate DBCC SHOWCONTIG Commands for All SQL Server Tables</title><link>https://www.sqlserver70.com/post/generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server/</link><pubDate>Fri, 01 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server/</guid><description>
&lt;h2 id="generate-dbcc-showcontig-commands-for-all-user-tables-in-sql-server"&gt;Generate DBCC SHOWCONTIG Commands for All User Tables in SQL Server&lt;/h2&gt;
&lt;p&gt;Database administrators frequently need to monitor table and index fragmentation to maintain optimal database performance. This SQL Server script provides an efficient way to generate DBCC SHOWCONTIG commands for all user tables in your database automatically.
&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;
&lt;h2 id="purpose"&gt;Purpose&lt;/h2&gt;
&lt;p&gt;The primary purpose of this script is to dynamically generate DBCC SHOWCONTIG commands for every user table in a SQL Server database. This eliminates the need to manually write individual commands for each table, saving time and ensuring comprehensive fragmentation analysis across all tables.&lt;/p&gt;</description></item><item><title>SQL Server Scripts and Commands: DBA Reference All Versions</title><link>https://www.sqlserver70.com/post/sql-server-scripts-database-commands/</link><pubDate>Fri, 01 Aug 2025 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-scripts-database-commands/</guid><description>
&lt;ul&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="sql-server-scripts-and-database-commands-65-70-80-90-100-1050-110-120-130-140-150-160-170"&gt;SQL Server Scripts and Database Commands 6.5, 7.0, 8.0, 9.0, 10.0, 10.50, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0&lt;/h2&gt;
&lt;p&gt;The corresponding version numbers and years: SQL Server 6.5 (1996), SQL Server 7.0 (1998), SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, SQL Server 2014, SQL Server 2016, SQL Server 2017, SQL Server 2019, SQL Server 2022, and SQL Server 2025&lt;/p&gt;
&lt;p&gt;We are in the process of building a list of simple scripts used every day by DBA and others. If you have your own scripts you reuse in a text file on you workstation please send it to us.&lt;/p&gt;</description></item><item><title/><link>https://www.sqlserver70.com/post/sql-server-log-backup-restore-chain-script-guide/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-log-backup-restore-chain-script-guide/</guid><description>
&lt;h1 id="sql-server-log-backup-restore-chain-script-guidemd"&gt;sql-server-log-backup-restore-chain-script-guide.md&lt;/h1&gt;
&lt;hr&gt;
&lt;p&gt;title: &amp;quot;SQL Server Log Backup Restore Chain Guide&amp;quot;
description: &amp;quot;Learn how to apply SQL Server full, differential, and transaction log backups in the correct restore chain sequence using NORECOVERY and RECOVERY options.&amp;quot;
keywords:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sql server restore chain&lt;/li&gt;
&lt;li&gt;transaction log backup restore&lt;/li&gt;
&lt;li&gt;NORECOVERY RECOVERY sql server&lt;/li&gt;
&lt;li&gt;restore database sql server&lt;/li&gt;
&lt;li&gt;full differential log restore&lt;/li&gt;
&lt;li&gt;msdb backupset query&lt;/li&gt;
&lt;li&gt;sql server backup restore sequence&lt;/li&gt;
&lt;li&gt;sql server log backup apply
tags:&lt;/li&gt;
&lt;li&gt;sql server&lt;/li&gt;
&lt;li&gt;restore&lt;/li&gt;
&lt;li&gt;backup&lt;/li&gt;
&lt;li&gt;transaction log&lt;/li&gt;
&lt;li&gt;NORECOVERY&lt;/li&gt;
&lt;li&gt;RECOVERY&lt;/li&gt;
&lt;li&gt;msdb&lt;/li&gt;
&lt;li&gt;database recovery
date: 2026-04-07
lastmod: 2026-04-11
showLastmod: true
categories:&lt;/li&gt;
&lt;li&gt;Scripts&lt;/li&gt;
&lt;li&gt;SQL Server Backup Recovery
series:&lt;/li&gt;
&lt;li&gt;admin-guide&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="sql-server-restore-chain-full-differential-and-log-backups"&gt;SQL Server Restore Chain: Full, Differential, and Log Backups&lt;/h2&gt;
&lt;p&gt;Restoring a SQL Server database to a specific point in time requires applying backups in the correct sequence. Getting the order wrong — or using the wrong recovery option — will break the restore chain and leave the database unusable.&lt;/p&gt;</description></item><item><title/><link>https://www.sqlserver70.com/post/sql-server-restore-database-script-with-move-option/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-restore-database-script-with-move-option/</guid><description>
&lt;h1 id="sql-server-restore-database-script-with-move-optionmd"&gt;sql-server-restore-database-script-with-move-option.md&lt;/h1&gt;
&lt;hr&gt;
&lt;p&gt;title: &amp;quot;SQL Server Restore Database Script with MOVE&amp;quot;
description: &amp;quot;Use dynamic SQL with the MOVE option to restore a SQL Server database and remap data and log file paths to any target directory on the server.&amp;quot;
keywords:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sql server restore database&lt;/li&gt;
&lt;li&gt;restore with move&lt;/li&gt;
&lt;li&gt;remap file paths&lt;/li&gt;
&lt;li&gt;dynamic sql restore&lt;/li&gt;
&lt;li&gt;RESTORE DATABASE&lt;/li&gt;
&lt;li&gt;RESTORE FILELISTONLY&lt;/li&gt;
&lt;li&gt;backup restore script&lt;/li&gt;
&lt;li&gt;sql server database recovery&lt;/li&gt;
&lt;li&gt;sp_executesql restore
tags:&lt;/li&gt;
&lt;li&gt;restore database&lt;/li&gt;
&lt;li&gt;backup recovery&lt;/li&gt;
&lt;li&gt;dynamic sql&lt;/li&gt;
&lt;li&gt;sql server&lt;/li&gt;
&lt;li&gt;RESTORE DATABASE&lt;/li&gt;
&lt;li&gt;RESTORE FILELISTONLY&lt;/li&gt;
&lt;li&gt;database administration&lt;/li&gt;
&lt;li&gt;scripts
date: 2026-04-09
lastmod: 2026-04-11
showLastmod: true
categories:&lt;/li&gt;
&lt;li&gt;Scripts&lt;/li&gt;
&lt;li&gt;SQL Server Backup Recovery
series:&lt;/li&gt;
&lt;li&gt;admin-guide
featured: false&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="restore-a-sql-server-database-with-file-path-remapping"&gt;Restore a SQL Server Database with File Path Remapping&lt;/h2&gt;
&lt;p&gt;Restoring a SQL Server database to a different server or folder often fails because the file paths in the backup do not match the target environment. The MOVE option in the RESTORE DATABASE statement lets you specify exactly where each data and log file should land.&lt;/p&gt;</description></item><item><title/><link>https://www.sqlserver70.com/post/sql-server-script-to-backup-all-databases-to-disk/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://www.sqlserver70.com/post/sql-server-script-to-backup-all-databases-to-disk/</guid><description>
&lt;h1 id="sql-server-script-to-backup-all-databases-to-diskmd"&gt;sql-server-script-to-backup-all-databases-to-disk.md&lt;/h1&gt;
&lt;hr&gt;
&lt;p&gt;title: &amp;quot;SQL Server Script to Backup All Databases to Disk&amp;quot;
description: &amp;quot;T-SQL script to back up all user databases to disk with dynamic date-stamped filenames. Automate full database backups in SQL Server using BACKUP DATABASE.&amp;quot;
keywords:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;sql server backup all databases&lt;/li&gt;
&lt;li&gt;backup database to disk&lt;/li&gt;
&lt;li&gt;date stamped backup filenames&lt;/li&gt;
&lt;li&gt;t-sql backup script&lt;/li&gt;
&lt;li&gt;sql server automated backup&lt;/li&gt;
&lt;li&gt;BACKUP DATABASE&lt;/li&gt;
&lt;li&gt;sys.databases&lt;/li&gt;
&lt;li&gt;sql server full backup&lt;/li&gt;
&lt;li&gt;dba backup script&lt;/li&gt;
&lt;li&gt;sql server database maintenance
tags:&lt;/li&gt;
&lt;li&gt;sql server&lt;/li&gt;
&lt;li&gt;backup&lt;/li&gt;
&lt;li&gt;database maintenance&lt;/li&gt;
&lt;li&gt;t-sql&lt;/li&gt;
&lt;li&gt;automation&lt;/li&gt;
&lt;li&gt;sys.databases&lt;/li&gt;
&lt;li&gt;dba scripts&lt;/li&gt;
&lt;li&gt;full backup
date: 2026-04-08
lastmod: 2026-04-11
showLastmod: true
categories:&lt;/li&gt;
&lt;li&gt;Scripts&lt;/li&gt;
&lt;li&gt;SQL Server Backup Recovery
series:&lt;/li&gt;
&lt;li&gt;admin-guide
featured: false
codeMaxLines: 60
codeLineNumbers: true&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="back-up-all-sql-server-user-databases-with-one-script"&gt;Back Up All SQL Server User Databases with One Script&lt;/h2&gt;
&lt;p&gt;Backing up every user database manually is time-consuming and error-prone. This T-SQL script loops through all online user databases and writes a compressed full backup for each one to disk, using a date- and time-stamped filename so backups never overwrite each other.&lt;/p&gt;</description></item></channel></rss>