<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQL Script Library Archives - The SERO Group</title>
	<atom:link href="https://theserogroup.com/category/sql-script-library/feed/" rel="self" type="application/rss+xml" />
	<link>https://theserogroup.com/category/sql-script-library/</link>
	<description>SQL Servers Healthy, Secure, And Reliable</description>
	<lastBuildDate>Fri, 13 Oct 2023 21:26:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://theserogroup.com/wp-content/uploads/2024/07/cropped-Canister-only-1-32x32.png</url>
	<title>SQL Script Library Archives - The SERO Group</title>
	<link>https://theserogroup.com/category/sql-script-library/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">121220030</site>	<item>
		<title>Vollgar: 6 Scripts to Help Review Your SQL Servers</title>
		<link>https://theserogroup.com/sql-server/vollgar-6-scripts-to-help-review-your-sql-servers/</link>
					<comments>https://theserogroup.com/sql-server/vollgar-6-scripts-to-help-review-your-sql-servers/#comments</comments>
		
		<dc:creator><![CDATA[Joe Webb]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 19:49:02 +0000</pubDate>
				<category><![CDATA[SQL Assess]]></category>
		<category><![CDATA[SQL Audit]]></category>
		<category><![CDATA[SQL Script Library]]></category>
		<category><![CDATA[SQL Security]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Script Library]]></category>
		<guid isPermaLink="false">http://theserogroup.com/?p=2747</guid>

					<description><![CDATA[<p>Last week, Guardicore released information about a newly discovered attack that uses SQL Servers to compromise servers and networks. Here&#8217;s a link; I&#8217;d really encourage you to read it. The attack known as Vollgar uses a simple brute force attack to gain access to SQL Servers exposed to the internet. It then uses the elevated&#8230; <br /> <a class="read-more" href="https://theserogroup.com/sql-server/vollgar-6-scripts-to-help-review-your-sql-servers/">Read more</a></p>
<p>The post <a href="https://theserogroup.com/sql-server/vollgar-6-scripts-to-help-review-your-sql-servers/">Vollgar: 6 Scripts to Help Review Your SQL Servers</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Last week, Guardicore released information about a newly discovered attack that uses SQL Servers to compromise servers and networks. Here&#8217;s a <a aria-label="link (opens in a new tab)" rel="noreferrer noopener" href="https://www.guardicore.com/2020/04/vollgar-ms-sql-servers-under-attack/" target="_blank">link</a>; I&#8217;d really encourage you to read it. The attack known as Vollgar uses a simple brute force attack to gain access to SQL Servers exposed to the internet. It then uses the elevated permissions of the compromised logins (sysadmin or serveradmin) to modify the capabilities of SQL Server and extended its access. </p>



<p><a rel="noreferrer noopener" aria-label="Guardicore has released a PowerShell script (opens in a new tab)" href="https://github.com/guardicore/labs_campaigns/tree/master/Vollgar" target="_blank">Guardicore has released a PowerShell script</a> that examines servers to determine if they’ve been infected.&nbsp;We’ve safely run the scripts on SQL Servers in our lab environment and for many of our clients. </p>



<p>If you routinely apply regular updates to your servers, practice the Principle of Least Privilege, regularly change critical passwords, have stringent password complexity requirements, and don&#8217;t expose your SQL Servers directly to the internet, the likelihood of a brute force attack succeeding is greatly reduced. </p>



<p>Here are six scripts that can help determine your level of potential exposure.</p>



<h3 class="wp-block-heading">Who Has sysadmin or serveradmin Privileges?</h3>



<p>The Vollgar attack is a brute force attack that attempts to guess the password for SQL Logins with elevated privileges. To be successful it needs logins that can execute <a rel="noreferrer noopener" aria-label="sp_configure (opens in a new tab)" href="https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-configure-transact-sql?view=sql-server-ver15" target="_blank">sp_configure</a> to change server-level settings. This are implicitly held by the sysadmin and serveradmin fixed server roles. </p>



<p>So, the first step in determining your exposure to Vollgar is to discover the members of the sysadmin and serveradmin roles. The following script will show you the members of each role. </p>



<pre class="wp-block-code"><code>USE master; 
GO

EXEC sp_helpsrvrolemember
	'sysadmin';

EXEC sp_helpsrvrolemember
	'serveradmin';</code></pre>



<p>In my sample database, the following is returned. </p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="941" height="518" src="http://theserogroup.com/wp-content/uploads/2020/04/server_role_members-1.png" alt="" class="wp-image-2771" srcset="https://theserogroup.com/wp-content/uploads/2020/04/server_role_members-1.png 941w, https://theserogroup.com/wp-content/uploads/2020/04/server_role_members-1-300x165.png 300w, https://theserogroup.com/wp-content/uploads/2020/04/server_role_members-1-768x423.png 768w" sizes="(max-width: 941px) 100vw, 941px" /></figure>



<p>Another approach to retrieving the same information in one consolidated result set is to use the following script. </p>



<pre class="wp-block-code"><code>--list of logins that are members of the sysadmin or serveradmin roles
SELECT SP1.&#91;name] AS 'Login',
	SP2.&#91;name] AS 'ServerRole'
FROM sys.server_principals AS SP1
	JOIN sys.server_role_members AS SRM 
		ON SP1.principal_id = SRM.member_principal_id
	JOIN sys.server_principals AS SP2 
		ON SRM.role_principal_id = SP2.principal_id
WHERE SP2.&#91;name] IN ('sysadmin', 'serveradmin')
ORDER BY SP2.&#91;name],
	 SP1.&#91;name];</code></pre>



<p>As expected, this script produces the same results. </p>



<figure class="wp-block-image size-large"><img decoding="async" width="594" height="325" src="http://theserogroup.com/wp-content/uploads/2020/04/server_role_members_v2-1.png" alt="" class="wp-image-2772" srcset="https://theserogroup.com/wp-content/uploads/2020/04/server_role_members_v2-1.png 594w, https://theserogroup.com/wp-content/uploads/2020/04/server_role_members_v2-1-300x164.png 300w" sizes="(max-width: 594px) 100vw, 594px" /></figure>



<p>Of course, it&#8217;s best practice to only grant the minimum rights required by each login, a practice known as least privilege. If these queries return more logins than absolutely necessary, it&#8217;s time to review your security practices. </p>



<h3 class="wp-block-heading">Who has Passwords that Do Not Expire and without Password Complexity Requirements?</h3>



<p>Having a complex password and changing it regularly is part of the basic blocking and tackling of security. Passwords like &#8220;Password123&#8221;, &#8220;Qwerty&#8221;, and &#8220;Puddles!&#8221; can be cracked in very short order using tools freely available on the web. And if these passwords never expire, users have no reason to change them regularly, making them even more of a liability.</p>



<p>For Windows Integrated Authentication, password complexity and expiration is handled at the network domain level. For SQL logins, these are enforced inside of SQL Server. </p>



<p>To find active SQL logins (e.g. not disabled) that do not require a basic level of complexity and are set to not expired, run the following script.</p>



<pre class="wp-block-code"><code>--Active SQL Logins where passwords do not expire
--and do not have complexity requirements 
SELECT name, 
	type_desc, 
	create_date, 
	modify_date, 
	default_database_name
FROM sys.sql_logins
WHERE is_expiration_checked = 0
	 AND is_disabled = 0 
	 AND is_policy_checked = 0 ; </code></pre>



<p>In my sample system, the script produces the following list. </p>



<figure class="wp-block-image size-large"><img decoding="async" width="956" height="330" src="http://theserogroup.com/wp-content/uploads/2020/04/password_dont_expire-1.png" alt="" class="wp-image-2773" srcset="https://theserogroup.com/wp-content/uploads/2020/04/password_dont_expire-1.png 956w, https://theserogroup.com/wp-content/uploads/2020/04/password_dont_expire-1-300x104.png 300w, https://theserogroup.com/wp-content/uploads/2020/04/password_dont_expire-1-768x265.png 768w" sizes="(max-width: 956px) 100vw, 956px" /></figure>



<p>Regularly changing passwords creates a moving target for potential attackers. If you have SQL logins that do not expire and do not have minimum complexity requirements, consider turning these features on for all your logins. </p>



<p>Putting some of the above queries together will give us a list of all active SQL logins that are members of the sysadmin or serveradmin fixed server roles along with whether their logins adhere to password complexity and expiration policies. </p>



<pre class="wp-block-code"><code>--list of SQL logins that are members of the sysadmin or serveradmin roles
SELECT SP1.&#91;name] AS 'Login',
	SP2.&#91;name] AS 'ServerRole',
	CASE l.is_disabled WHEN 1 THEN 'No' ELSE 'Yes' END AS Is_Enabled,
	CASE l.is_expiration_checked WHEN 1 THEN 'Yes' ELSE 'No' End AS Pwd_Expires,
	CASE l.is_policy_checked WHEN 1 THEN 'Yes' ELSE 'No' END AS Pwd_Complexity_Reqs
FROM sys.server_principals AS SP1
	JOIN sys.server_role_members AS SRM
	ON SP1.principal_id = SRM.member_principal_id
	JOIN sys.server_principals AS SP2
	ON SRM.role_principal_id = SP2.principal_id
	JOIN sys.sql_logins AS l
	ON l.principal_id = SRM.member_principal_id
WHERE SP2.&#91;name] IN ('sysadmin', 'serveradmin')
ORDER BY SP2.&#91;name],
	 SP1.&#91;name];</code></pre>



<p>The following results are returned on my test system.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="802" height="274" src="http://theserogroup.com/wp-content/uploads/2020/04/elevated_privileges.png" alt="" class="wp-image-2783" srcset="https://theserogroup.com/wp-content/uploads/2020/04/elevated_privileges.png 802w, https://theserogroup.com/wp-content/uploads/2020/04/elevated_privileges-300x102.png 300w, https://theserogroup.com/wp-content/uploads/2020/04/elevated_privileges-768x262.png 768w" sizes="auto, (max-width: 802px) 100vw, 802px" /></figure>



<h3 class="wp-block-heading">When was a SQL Login Password Changed?</h3>



<p>From the prior two queries, we can see that Alice and Donnie are both active members of the sysadmin fixed server role. Donnie&#8217;s password doesn&#8217;t expire and doesn&#8217;t have to meet any password complexity requirements. Of course, this is a big red flag for security. Alice&#8217;s login, on the other hand, is set to adhere to complexity and expiration requirements. That&#8217;s good. </p>



<p>But how long has it been since Alice actually changed her password? We can use the <a rel="noreferrer noopener" aria-label="LOGINPROPERTY() (opens in a new tab)" href="https://docs.microsoft.com/en-us/sql/t-sql/functions/loginproperty-transact-sql?view=sql-server-ver15" target="_blank">LOGINPROPERTY()</a> function to help us. Note: that for the function to return meaningful information, both  CHECK_POLICY and CHECK_EXPIRATION must be enabled for the login.</p>



<pre class="wp-block-code"><code>--when was a login's password last changed?
SELECT 'Alice' AS username,
	LOGINPROPERTY('Alice', 'PasswordLastSetTime') AS PasswordLastSetTime;</code></pre>



<p>In this case, we can see that Alice last set her password on March 26, 2020. </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="435" height="110" src="http://theserogroup.com/wp-content/uploads/2020/04/password_last_changed-1.png" alt="" class="wp-image-2774" srcset="https://theserogroup.com/wp-content/uploads/2020/04/password_last_changed-1.png 435w, https://theserogroup.com/wp-content/uploads/2020/04/password_last_changed-1-300x76.png 300w" sizes="auto, (max-width: 435px) 100vw, 435px" /></figure>



<p>We can use other properties in the LOGINPROPERTY() function, such as BadPasswordCount and BadPasswordTime.  I wouldn&#8217;t rely too heavily on the results, though. The BadPasswordCount is reset to 0 as soon as Alice successfully logs in. And, just as importantly, it&#8217;s only relevant for those SQL Logins who have  CHECK_POLICY and CHECK_EXPIRATION enabled. </p>



<pre class="wp-block-code"><code>--bad password attempts
SELECT name, 
	LOGINPROPERTY(name, 'BadPasswordCount') AS BadPasswordCount,
	LOGINPROPERTY(name, 'BadPasswordTime') AS BadPasswordTime
FROM sys.sql_logins 
WHERE is_expiration_checked = 1
	AND is_disabled = 0 
	AND is_policy_checked = 1; </code></pre>



<p>The results from my test system are shown below. </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="693" height="490" src="http://theserogroup.com/wp-content/uploads/2020/04/bad_attempts-1.png" alt="" class="wp-image-2768" srcset="https://theserogroup.com/wp-content/uploads/2020/04/bad_attempts-1.png 693w, https://theserogroup.com/wp-content/uploads/2020/04/bad_attempts-1-300x212.png 300w" sizes="auto, (max-width: 693px) 100vw, 693px" /></figure>



<h3 class="wp-block-heading">How to See Failed Login Attempts</h3>



<p>Assuming your SQL Server is configured to log failed login attempts, and of course it should be, you can query the error log files using the sp_readerrorlog procedure to see the failed attempts. </p>



<pre class="wp-block-code"><code>EXEC sp_readerrorlog 0, 1, 'Login failed' ;</code></pre>



<p>The following is returned on my test system.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="862" height="273" src="http://theserogroup.com/wp-content/uploads/2020/04/error_log_files-1.png" alt="" class="wp-image-2769" srcset="https://theserogroup.com/wp-content/uploads/2020/04/error_log_files-1.png 862w, https://theserogroup.com/wp-content/uploads/2020/04/error_log_files-1-300x95.png 300w, https://theserogroup.com/wp-content/uploads/2020/04/error_log_files-1-768x243.png 768w" sizes="auto, (max-width: 862px) 100vw, 862px" /></figure>



<p>Better yet, use a monitoring tool to proactively monitor failed login attempts and alert when a minimum threshold is exceeded. For our <a rel="noreferrer noopener" aria-label="DBA as a Service (opens in a new tab)" href="http://theserogroup.com/#how-we-help" target="_blank">DBA as a Service</a> clients, we provide <a rel="noreferrer noopener" aria-label="SentryOne (opens in a new tab)" href="https://www.sentryone.com/" target="_blank">SentryOne</a>&#8216;s <a rel="noreferrer noopener" aria-label="SQLSentry  (opens in a new tab)" href="https://www.sentryone.com/products/sentryone-platform/sql-sentry/sql-server-performance-monitoring" target="_blank">SQLSentry </a>monitoring tool to help with this and other events that should be monitored.</p>



<h3 class="wp-block-heading">Parting Thoughts</h3>



<p>Many years ago, I set up a test system for a writing project I was involved with. As part of the test, I set the sa password to something like &#8220;Cat123Dog!&#8221; The password met most requirements of the day &#8211; upper and lower case, at least one number and one letter, and a special symbol. &#8220;Not bad,&#8221; I thought to myself.</p>



<p>Then I downloaded <a rel="noreferrer noopener" aria-label="Ophcrack (opens in a new tab)" href="https://ophcrack.sourceforge.io/" target="_blank">Ophcrack</a>, a free Windows password cracker, and released it on my unsuspecting SQL Server. Expecting the utility to run for hours, if not days, I returned to work. </p>



<p>A few minutes later, I decided to check on it, wanting to make sure it wasn&#8217;t hung for some reason. I was stunned. Ophcrack had already found the password! That was at least 10 years ago. I&#8217;m sure the tools of the hacker trade have gotten much better since then. </p>



<p>Recently, I&#8217;ve read where most breaches are a result of social engineering &#8211; someone receives an e-Card from a secret admirer, finds a thumb drive in the parking lot, or clicks an email link. &#8220;The days of brute force attacks are over,&#8221; they say. </p>



<p>Vollgar has proven them wrong. Basic security measures are still best practice. You owe it to yourself to make sure you&#8217;re doing it well. Here are a few links that may help.</p>



<ul class="wp-block-list"><li><a rel="noreferrer noopener" aria-label="Introduction to SQL Server Security (opens in a new tab)" href="https://www.red-gate.com/simple-talk/sysadmin/data-protection-and-privacy/introduction-to-sql-server-security-part-1/" target="_blank">Introduction to SQL Server Security</a></li><li><a rel="noreferrer noopener" aria-label="Securing SQL Server (opens in a new tab)" href="https://docs.microsoft.com/en-us/sql/relational-databases/security/securing-sql-server?view=sql-server-ver15" target="_blank">Securing SQL Server</a></li><li><a href="https://www.mssqltips.com/sqlservertip/3159/sql-server-security-checklist/" target="_blank" rel="noreferrer noopener" aria-label="SQL Server Security Checklist (opens in a new tab)">SQL Server Security Checklist</a></li></ul>
<p>The post <a href="https://theserogroup.com/sql-server/vollgar-6-scripts-to-help-review-your-sql-servers/">Vollgar: 6 Scripts to Help Review Your SQL Servers</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theserogroup.com/sql-server/vollgar-6-scripts-to-help-review-your-sql-servers/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2747</post-id>	</item>
		<item>
		<title>Is There an Update for My SQL Server?</title>
		<link>https://theserogroup.com/sql-server/is-there-an-update-for-my-sql-server/</link>
					<comments>https://theserogroup.com/sql-server/is-there-an-update-for-my-sql-server/#comments</comments>
		
		<dc:creator><![CDATA[Joe Webb]]></dc:creator>
		<pubDate>Tue, 31 Mar 2020 17:58:45 +0000</pubDate>
				<category><![CDATA[SQL Audit]]></category>
		<category><![CDATA[SQL Script Library]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Script Library]]></category>
		<category><![CDATA[SQL Upgrades]]></category>
		<guid isPermaLink="false">http://theserogroup.com/?p=2718</guid>

					<description><![CDATA[<p>We&#8217;ve all asked that question at some point. Maybe we inherited a new-to-us SQL Server that hasn&#8217;t been maintained regularly. Or, perhaps we&#8217;re prepping for a maintenance window and we want to get the latest update into Test as soon as possible. Regardless, we want to know two things. First, what product version is my&#8230; <br /> <a class="read-more" href="https://theserogroup.com/sql-server/is-there-an-update-for-my-sql-server/">Read more</a></p>
<p>The post <a href="https://theserogroup.com/sql-server/is-there-an-update-for-my-sql-server/">Is There an Update for My SQL Server?</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>We&#8217;ve all asked that question at some point. Maybe we inherited a new-to-us SQL Server that hasn&#8217;t been maintained regularly. Or, perhaps we&#8217;re prepping for a maintenance window and we want to get the latest update into Test as soon as possible. Regardless, we want to know two things. First, what product version is my SQL Server currently running? And second, what is the most recent update? </p>



<h3 class="wp-block-heading">What version is my SQL Server currently running?</h3>



<p>There are several ways to check the version of SQL Server you&#8217;re currently running &#8211; all of them documented in countless places on the the web. Checking the instance property page in Management Studio and executing SELECT @@VERSION are two of the more common. </p>



<p>My preference is to run the following script using <a rel="noreferrer noopener" aria-label="SERVERPROPERTY (opens in a new tab)" href="https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-ver15" target="_blank">SERVERPROPERTY</a>. When used in combination with <a rel="noreferrer noopener" aria-label="Central Management Server (opens in a new tab)" href="https://docs.microsoft.com/en-us/sql/ssms/register-servers/create-a-central-management-server-and-server-group?view=sql-server-ver15" target="_blank">Central Management Server</a>, you can check the current level for all the SQL Server instances in your environment with one click of the Execute button. </p>



<pre class="wp-block-code"><code>SELECT
	SERVERPROPERTY('servername') AS Server_Name,
	SERVERPROPERTY('edition') AS Edition,
	SERVERPROPERTY('productlevel') AS Product_Level, 
	SERVERPROPERTY('productversion') AS Product_Version,
	SERVERPROPERTY('productupdatelevel') AS Product_Update_Level,
	SERVERPROPERTY('productupdatereference') AS Product_Update_Reference,
	SERVERPROPERTY('resourceversion') AS Resource_Version, 
	@@VERSION AS Version_Information </code></pre>



<p>Running the query on my Docker container instance returns the following.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="916" height="76" src="http://theserogroup.com/wp-content/uploads/2020/03/ssms_results-1.png" alt="" class="wp-image-2731" srcset="https://theserogroup.com/wp-content/uploads/2020/03/ssms_results-1.png 916w, https://theserogroup.com/wp-content/uploads/2020/03/ssms_results-1-300x25.png 300w, https://theserogroup.com/wp-content/uploads/2020/03/ssms_results-1-768x64.png 768w" sizes="auto, (max-width: 916px) 100vw, 916px" /></figure>



<p>Keep in mind that SERVERPROPERTY can behave slightly differently for older versions of SQL Server. ProductUpdateLevel and ProductUpdateReference, for instance, were introduced as part of SQL Server 2012. When run against an older version, such as SQL Server 2005, these will return NULL. </p>



<p>Running against another older SQL Server produces the following. Still, it gives you the information you need.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="978" height="84" src="http://theserogroup.com/wp-content/uploads/2020/03/ssms_results2-1.png" alt="" class="wp-image-2736" srcset="https://theserogroup.com/wp-content/uploads/2020/03/ssms_results2-1.png 978w, https://theserogroup.com/wp-content/uploads/2020/03/ssms_results2-1-300x26.png 300w, https://theserogroup.com/wp-content/uploads/2020/03/ssms_results2-1-768x66.png 768w" sizes="auto, (max-width: 978px) 100vw, 978px" /></figure>



<p>So, is that up to date or not for this version of SQL Server? </p>



<h3 class="wp-block-heading">What is the latest update level for my version of SQL Server? </h3>



<p>To answer that question, let&#8217;s turn to the definitive source &#8211; Microsoft. Microsoft has gotten into a fairly predictable cadence of regularly releasing updates for SQL Server. To help us keep track of the releases they&#8217;ve provided a <a rel="noreferrer noopener" aria-label="SQL Docs page that lists all versions of SQL Server (opens in a new tab)" href="https://docs.microsoft.com/en-us/sql/database-engine/install-windows/latest-updates-for-microsoft-sql-server?view=sql-server-ver15&amp;_lrsc=17f3dde9-1a6c-467a-ad87-c08ff7c03f42" target="_blank">SQL Docs page that lists all versions of SQL Server</a> for the past 20 years. Yes, all the way back to SQL Server 2000. </p>



<p>The list shows the Product Version, the Latest Service Pack (if applicable), the Latest GDR (General Distribution Release), the Latest cumulative update (CU), the CU Release Date, and a link to some General Guidance for the each version. Here&#8217;s what the site looks like today, March 31, 2020. </p>



<figure class="wp-block-image size-large"><a href="https://docs.microsoft.com/en-us/sql/database-engine/install-windows/latest-updates-for-microsoft-sql-server?view=sql-server-ver15&amp;_lrsc=17f3dde9-1a6c-467a-ad87-c08ff7c03f42" target="_blank" rel="noreferrer noopener"><img loading="lazy" decoding="async" width="1024" height="650" src="http://theserogroup.com/wp-content/uploads/2020/03/Latest_Updates-1024x650.png" alt="" class="wp-image-2724" srcset="https://theserogroup.com/wp-content/uploads/2020/03/Latest_Updates-1024x650.png 1024w, https://theserogroup.com/wp-content/uploads/2020/03/Latest_Updates-300x190.png 300w, https://theserogroup.com/wp-content/uploads/2020/03/Latest_Updates-768x487.png 768w, https://theserogroup.com/wp-content/uploads/2020/03/Latest_Updates.png 1473w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>Not sure of the difference in a SP, GDR, and CU? Here&#8217;s a <a rel="noreferrer noopener" aria-label="blog post I wrote 12 years ago when I blogged at SQLTeam (opens in a new tab)" href="https://weblogs.sqlteam.com/joew/2008/05/07/60591/" target="_blank">blog post I wrote 12 years ago when I blogged at SQLTeam</a> that explains the vernacular. </p>



<h3 class="wp-block-heading">Additional Information</h3>



<p>Here are a few other links that may help. </p>



<ul class="wp-block-list"><li><a rel="noreferrer noopener" aria-label="SQL Server Release Blog (opens in a new tab)" href="https://aka.ms/sqlreleases" target="_blank">SQL Server Release Blog</a> &#8211; A Micosoft Tech Community blog dedicated to SQL Server Releases.</li><li><a rel="noreferrer noopener" aria-label="SQL Server Builds Blog (opens in a new tab)" href="https://sqlserverbuilds.blogspot.com/" target="_blank">SQL Server Builds Blog</a> &#8211; I particularly like this blog since it shows each version along with relevant build numbers. </li><li><a rel="noreferrer noopener" aria-label="SQL Server Updates  (opens in a new tab)" href="https://sqlserverupdates.com/" target="_blank">SQL Server Updates </a> &#8211; Brent Ozar also maintains a great site for keeping track of version update information. </li></ul>
<p>The post <a href="https://theserogroup.com/sql-server/is-there-an-update-for-my-sql-server/">Is There an Update for My SQL Server?</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theserogroup.com/sql-server/is-there-an-update-for-my-sql-server/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2718</post-id>	</item>
		<item>
		<title>Want to Learn SQL Server? Here Are 3 Free Sources</title>
		<link>https://theserogroup.com/training/want-to-learn-sql-server-here-are-3-free-sources/</link>
					<comments>https://theserogroup.com/training/want-to-learn-sql-server-here-are-3-free-sources/#comments</comments>
		
		<dc:creator><![CDATA[Joe Webb]]></dc:creator>
		<pubDate>Mon, 12 Aug 2019 20:31:46 +0000</pubDate>
				<category><![CDATA[Career Development]]></category>
		<category><![CDATA[Professional Development]]></category>
		<category><![CDATA[SQL Audit]]></category>
		<category><![CDATA[SQL Community]]></category>
		<category><![CDATA[SQL Script Library]]></category>
		<category><![CDATA[SQL Security]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Consulting]]></category>
		<category><![CDATA[The Sero Group]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[Work/Life Balance]]></category>
		<category><![CDATA[Resources]]></category>
		<guid isPermaLink="false">http://theserogroup.com/?p=2512</guid>

					<description><![CDATA[<p>Many companies have lean IT organizations and find themselves with five, ten, or even twenty production SQL Servers and no dedicated Database Administrator to care for them. Instead, they rely on other IT Professionals to ensure the database servers are performant. We&#8217;ve worked with many companies where SysAdmins, Application Developers, and Network Administrators have been&#8230; <br /> <a class="read-more" href="https://theserogroup.com/training/want-to-learn-sql-server-here-are-3-free-sources/">Read more</a></p>
<p>The post <a href="https://theserogroup.com/training/want-to-learn-sql-server-here-are-3-free-sources/">Want to Learn SQL Server? Here Are 3 Free Sources</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-drop-cap">Many companies have lean IT organizations and find themselves with five, ten, or even twenty production SQL Servers and no dedicated Database Administrator to care for them. Instead, they rely on other IT Professionals to ensure the database servers are performant. We&#8217;ve worked with many companies where SysAdmins, Application Developers, and Network Administrators have been regularly tasked to perform double duty, taking care of their primary responsibilities while also responding to SQL Server issues. Those IT professionals are looking to learn enough SQL Server to help them accomplish what they need to do. </p>



<h1 class="wp-block-heading" id="h-free-sql-server-training-resources">Free SQL Server Training Resources</h1>



<p>Often these IT Professionals, sometimes called &#8220;Accidental DBAs,&#8221; do an admirable job, even with little formal SQL Server training. Fortunately, there are a lot of great resources available online for the &#8220;Accidental DBA.&#8221; Here are a few free SQL Server learning resources worth checking out:</p>



<h2 class="wp-block-heading" id="h-1-microsoft-resources-and-labs"><strong>1. Microsoft Resources and Labs</strong></h2>



<p>Microsoft has put together quite a few learning opportunities available to the public for free. These are in several different formats so you can pick the one you&#8217;re most comfortable with. Here are a few you may want to check out:</p>



<ol class="wp-block-list">
<li><a rel="noreferrer noopener" aria-label="Microsoft SQL Server 2019 (CTP 3.2) Lab (opens in a new tab)" href="https://github.com/microsoft/sqlworkshops/tree/master/sql2019lab" target="_blank">Microsoft SQL Server 2019 (CTP 3.2) Lab</a>. In this self-paced lab, you&#8217;ll learn how to use SQL Server 2019 to solve business challenges.</li>



<li><a rel="noreferrer noopener" aria-label="Microsoft AI School (opens in a new tab)" href="https://aischool.microsoft.com/en-us/home" target="_blank">Microsoft AI School</a>. Artificial Intelligence is a hot topic in today&#8217;s business environment. In Microsoft AI School, you&#8217;ll &#8220;find the information, learning materials, and resources you need to start building intelligence into your solutions.&#8221;</li>



<li><a rel="noreferrer noopener" aria-label="SQL Server Tutorials (opens in a new tab)" href="https://docs.microsoft.com/en-us/sql/sql-server/tutorials-for-sql-server-2016?view=sql-server-ver15" target="_blank">SQL Server Tutorials</a>. More than just Online Documentation, SQL Docs is a great place for detailed information about how to use SQL Server. It includes tutorials that will step you through learning the database technology.</li>



<li><a rel="noreferrer noopener" aria-label="EdX (opens in a new tab)" href="https://www.edx.org/about-us" target="_blank">EdX</a>. Founded by Harvard and MIT, EdX is a place where education is freely available to everyone online. Microsoft has partnered with EdX to provide free courses online for SQL Server. Here are a few:
<ul class="wp-block-list">
<li><a rel="noreferrer noopener" aria-label="Querying Data with Transact-SQL (opens in a new tab)" href="https://www.edx.org/course/querying-data-with-transact-sql-3" target="_blank">Querying Data with Transact-SQL</a>.</li>



<li><a rel="noreferrer noopener" aria-label="Developing SQL Databases (opens in a new tab)" href="https://www.edx.org/course/developing-sql-databases" target="_blank">Developing SQL Databases</a>.</li>



<li><a rel="noreferrer noopener" aria-label="Analyzing and Visualizing Data with SQL Server Reporting Services (opens in a new tab)" href="https://www.edx.org/course/analyzing-visualizing-data-sql-server-microsoft-dat214x-2" target="_blank">Analyzing and Visualizing Data with SQL Server Reporting Services</a>. </li>
</ul>
</li>



<li><a rel="noreferrer noopener" aria-label="Channel 9 (opens in a new tab)" href="https://channel9.msdn.com/Search?term=sql&amp;sortBy=recent&amp;lang-en=true" target="_blank">Channel 9</a>. Microsoft produces a lot of video content for SQL Server and other products. They make it available online via Channel 9.</li>
</ol>



<h2 class="wp-block-heading" id="h-2-youtub-e-channels"><strong>2. YouTub</strong>e Channels</h2>



<p>YouTube can be a great resource for learning just about anything. From changing a tire to playing the ukulele, you can find it on YouTube. It should come as no surprise that there are a lot of great SQL Server training videos available as well. Of course, since just about anyone can create a video, you&#8217;ll want to be careful. Not everyone is the expert that they portend to be online. Do your own research. Here are a couple of places to start.</p>



<ol class="wp-block-list">
<li><a rel="noreferrer noopener" aria-label="SQL Server YouTube Search (opens in a new tab)" href="https://www.youtube.com/results?search_query=sql+server" target="_blank">SQL Server YouTube Search</a>. A list of SQL Server-related videos. </li>



<li><a rel="noreferrer noopener" aria-label="Microsoft SQL Server YouTube Channel (opens in a new tab)" href="https://www.youtube.com/channel/UC_BLf95QgWpwlbSq-ZKLMwA" target="_blank">Microsoft SQL Server YouTube Channel</a>. Microsoft SQL Server home on YouTube.</li>
</ol>



<h2 class="wp-block-heading" id="h-3-sqlsaturdays-and-virtual-groups">3. SQLSaturdays and Virtual Groups</h2>



<p>For many years, I was on the board of Directors for a global user group called <a rel="noreferrer noopener" aria-label="PASS (opens in a new tab)" href="https://www.pass.org/" target="_blank">PASS</a>. The organization is committed to providing learning opportunities for professionals around the globe and to helping the community to better connect with one another. There are a couple of ways PASS helps with this. </p>



<ol class="wp-block-list">
<li><a rel="noreferrer noopener" aria-label="SQLSaturdays (opens in a new tab)" href="https://www.sqlsaturday.com/" target="_blank">SQLSaturdays</a> are a series of free one-day training events in cities around the world. These events, as the name suggests are held on Saturdays and are free to attend. They typically have some of the best and most well-known SQL Server experts around. Look for a SQLSaturday near you and plan to attend. You&#8217;ll see some great content and better yet make some incredible connections. </li>



<li><a rel="noreferrer noopener" aria-label="Virtual Groups (opens in a new tab)" href="https://www.pass.org/Community/Groups/PASSVirtualGroups.aspx" target="_blank">Virtual Groups</a>. Through live webinars, PASS Virtual Groups offer top-notch training no matter where you happen to be. Check out a list of upcoming webinars. </li>
</ol>



<h2 class="wp-block-heading" id="h-summary">Summary</h2>



<p>With a new release every 18 to 24 months, keeping up with the latest changes can be a challenge. Hopefully, these free resources will help. We also have an ever growing<a href="https://theserogroup.com/category/sql-script-library/"> SQL Script Library</a> available to help get you started with some of the more common tasks. </p>



<h2 class="wp-block-heading" id="h-want-to-work-with-the-sero-group">Want to work with The Sero Group?</h2>



<p>Want to learn more about how SERO Group helps organizations take the guesswork out of managing their SQL Servers? It’s easy and there is no obligation.&nbsp;</p>



<p><a href="https://theserogroup.com/#contact" target="_blank" rel="noreferrer noopener">Schedule a call</a> with us to get started.</p>
<p>The post <a href="https://theserogroup.com/training/want-to-learn-sql-server-here-are-3-free-sources/">Want to Learn SQL Server? Here Are 3 Free Sources</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theserogroup.com/training/want-to-learn-sql-server-here-are-3-free-sources/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2512</post-id>	</item>
		<item>
		<title>How Many tempdb Data Files Should My SQL Server Have?</title>
		<link>https://theserogroup.com/sql-server/how-many-tempdb-data-files-should-my-sql-server-have/</link>
					<comments>https://theserogroup.com/sql-server/how-many-tempdb-data-files-should-my-sql-server-have/#comments</comments>
		
		<dc:creator><![CDATA[Joe Webb]]></dc:creator>
		<pubDate>Tue, 02 Jul 2019 13:30:58 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[SQL Assess]]></category>
		<category><![CDATA[SQL Script Library]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[Database Development]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Script Library]]></category>
		<category><![CDATA[Sero]]></category>
		<category><![CDATA[Sero Group]]></category>
		<category><![CDATA[SQL Audit]]></category>
		<category><![CDATA[SQL Consultant]]></category>
		<category><![CDATA[SQL Server Consultant]]></category>
		<category><![CDATA[SQL Server Management]]></category>
		<category><![CDATA[TempDB]]></category>
		<category><![CDATA[The Sero Group]]></category>
		<guid isPermaLink="false">http://theserogroup.com/?p=2433</guid>

					<description><![CDATA[<p>We&#8217;re frequently asked how many tempdb files a SQL Server should have, especially from those who have downloaded our free&#160;5 Common SQL Server Configuration Issues PDF. That&#8217;s&#160;because there&#8217;s a lot of well-intended but incorrect information posted on the internet about tempdb.&#160; What Is tempdb? Let&#8217;s start with a very brief description of tempdb. When SQL&#8230; <br /> <a class="read-more" href="https://theserogroup.com/sql-server/how-many-tempdb-data-files-should-my-sql-server-have/">Read more</a></p>
<p>The post <a href="https://theserogroup.com/sql-server/how-many-tempdb-data-files-should-my-sql-server-have/">How Many tempdb Data Files Should My SQL Server Have?</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>We&#8217;re frequently asked how many tempdb files a SQL Server should have, especially from those who have downloaded our free&nbsp;<a rel="noreferrer noopener" href="http://theserogroup.com/#common-issues" target="_blank">5 Common SQL Server Configuration Issues PDF</a>. That&#8217;s&nbsp;because there&#8217;s a lot of well-intended but incorrect information posted on the internet about tempdb.&nbsp;</p>



<h2 class="wp-block-heading">What Is tempdb? </h2>



<p>Let&#8217;s start with a very brief description of tempdb. When SQL Server needs some additional workspace to resolve a query, it uses a built-in system database called tempdb. A query&nbsp;may use tempdb for sorting operations, cursors, temporary tables, or even aggregation operations among other things. Since there is only one tempdb database for each SQL Server instance, it can be quite heavily used.&nbsp;</p>



<p>By default, when you install SQL Server, one&nbsp;data file is created for the tempdb database. Having only one data file, however, can hinder SQL Server&#8217;s performance. The solitary file can become a bottleneck for queries that require tempdb. This is a pretty common issue, in fact, it made our&nbsp;<a rel="noreferrer noopener" href="http://www.theserogroup.com/#common-issues" target="_blank">Top 5 List</a>.&nbsp;</p>



<h2 class="wp-block-heading">How Many tempdb Files Do You Need?</h2>



<p>So, if the default value is likely not right for you, how many tempdb&nbsp;data files should you have? The answer is: it depends.&nbsp;According to&nbsp;<a rel="noreferrer noopener" href="https://support.microsoft.com/en-us/help/2154845/recommendations-to-reduce-allocation-contention-in-sql-server-tempdb-d" target="_blank">Microsoft Support</a>, the best approach is to create one tempdb data file per logical processor up to 8 data files. </p>



<p>If your system has more than 8 logical processors, start with 8 data files and monitor your server&#8217;s workload to determine if more data files would be beneficial.&nbsp;If you do find that an increase is warranted, add 4 data files at a time, but do not add more than the number of logical processors.</p>



<h2 class="wp-block-heading">How Many tempdb Files Do You Have?</h2>



<p>How many tempdb data files does your SQL Server have? A fairly straightforward query can answer the question.&nbsp;Open Management Studio and run the following query.</p>



<pre class="wp-block-code"><code>--tell me about my tempdb
SELECT
  f.name AS &#91;file_name],
  CAST((f.size / 128.0) AS DECIMAL(15, 2)) AS &#91;size_in_MB],
  CAST(f.size / 128.0 - CAST(FILEPROPERTY(f.name, 'SpaceUsed') AS INT) / 128.0 AS DECIMAL(15, 2)) AS &#91;space_available_in_MB],
  &#91;file_id] AS &#91;file_id],
  ISNULL(fg.name, 'LOG') AS &#91;filegroup_name],
  f.physical_name AS &#91;physical_name]
FROM sys.master_files AS f
LEFT OUTER JOIN sys.data_spaces AS fg
  ON f.data_space_id = fg.data_space_id
WHERE f.database_id = 2;</code></pre>



<p>You&#8217;ll notice that the results from the&nbsp;query above&nbsp;include the folder location for each tempdb file. That&#8217;s because file placement can also have a dramatic impact on performance and even reliability. But that&#8217;s another story.</p>



<p>For more information about tempdb, check out&nbsp;<a rel="noreferrer noopener" href="https://jwebb.me/ms_doc_tempdb" target="_blank">Microsoft&#8217;s SQL Docs</a>.&nbsp;</p>



<p>Want to know more about other configuration options that could affect performance and reliability? Check out <a href="https://theserogroup.com/2019/08/06/is-my-sql-server-configured-properly/" target="_blank" rel="noreferrer noopener">Is My SQL Server Configured Properly?</a></p>



<p>[EDIT Oct 5, 2021] &#8211; Also see <a href="https://theserogroup.com/dba/how-to-configure-sql-server-tempdb/">How to Configure SQL Server tempdb?</a> for other tempdb configuration settings that can affect performance. </p>



<h2 class="wp-block-heading">Want to work with The Sero Group?</h2>



<p>Want to learn more about how SERO Group helps organizations take the guesswork out of managing their SQL Servers? It’s easy and there is no obligation. </p>



<p><a href="https://calendly.com/joe_webb">Schedule a call</a> with us to get started.</p>
<p>The post <a href="https://theserogroup.com/sql-server/how-many-tempdb-data-files-should-my-sql-server-have/">How Many tempdb Data Files Should My SQL Server Have?</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theserogroup.com/sql-server/how-many-tempdb-data-files-should-my-sql-server-have/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2433</post-id>	</item>
		<item>
		<title>Script: How Long Until My SQL Server Backup/Restore Completes?</title>
		<link>https://theserogroup.com/sql-server/script-how-long-until-my-sql-server-backup-restore-completes/</link>
					<comments>https://theserogroup.com/sql-server/script-how-long-until-my-sql-server-backup-restore-completes/#comments</comments>
		
		<dc:creator><![CDATA[Joe Webb]]></dc:creator>
		<pubDate>Tue, 13 Nov 2018 16:20:17 +0000</pubDate>
				<category><![CDATA[SQL Script Library]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[Script Library]]></category>
		<guid isPermaLink="false">http://theserogroup.com/?p=2269</guid>

					<description><![CDATA[<p>Ding!&#160; Your desktop IM client chimes. &#8220;Any idea how long my SQL Server backup/restore will take to complete? I think it may be stuck.&#8221;&#160; Someone has started a database restore (or backup) using a T-SQL command. Now he wants to know how long the process will take to complete. He&#8217;s gone to the bathroom and&#8230; <br /> <a class="read-more" href="https://theserogroup.com/sql-server/script-how-long-until-my-sql-server-backup-restore-completes/">Read more</a></p>
<p>The post <a href="https://theserogroup.com/sql-server/script-how-long-until-my-sql-server-backup-restore-completes/">Script: How Long Until My SQL Server Backup/Restore Completes?</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Ding!&nbsp; Your desktop IM client chimes. &#8220;Any idea how long my SQL Server backup/restore will take to complete? I think it may be stuck.&#8221;&nbsp;</p>



<p>Someone has started a database restore (or backup) using a T-SQL command. Now he wants to know how long the process will take to complete. He&#8217;s gone to the bathroom and even gotten a coffee, yet it&#8217;s still running.&nbsp;</p>



<p>If he had used the WITH STATS option for either the <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql?view=sql-server-2017" target="_blank" rel="noopener">BACKUP DATABASE</a> or <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/restore-statements-transact-sql?view=sql-server-2017" target="_blank" rel="noopener">RESTORE DATABASE</a> command, the percentage processed would have been piped to the Messages tab of Management Studio a little at a time. 10 percent processed. 20 percent processed. And so on as shown below.</p>



<pre class="wp-block-code"><code>BACKUP DATABASE wideworldimporters TO DISK = 'c:\temp\wwi.bak' WITH STATS;</code></pre>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="640" height="239" src="http://theserogroup.com/wp-content/uploads/2018/11/Messages.png" alt="" class="wp-image-2272" srcset="https://theserogroup.com/wp-content/uploads/2018/11/Messages.png 640w, https://theserogroup.com/wp-content/uploads/2018/11/Messages-300x112.png 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>



<h2 class="wp-block-heading" id="h-sql-server-backup-restore-information-using-dmvs">SQL Server backup/restore information using DMVs</h2>



<p>Still, that doesn&#8217;t provide an estimate of how long the process is likely <g class="gr_ gr_12 gr-alert sel gr_gramm gr_replaced gr_inline_cards gr_disable_anim_appear Grammar only-ins replaceWithoutSep" id="12" data-gr-id="12">to </g>run. Fortunately, the Dynamic Management Views in SQL Server allow us to gather and report backup and restore estimates.</p>



<p>Here&#8217;s a script that I&#8217;ve found useful. It&#8217;s an amalgamation of <a href="https://jwebb.me/2Ppz0MR" target="_blank" rel="noopener">a script I found on StackOverflow</a> and my own handiwork. As always, this is for your reference only and no guarantees are implied.</p>



<pre class="wp-block-code"><code>SELECT SERVERPROPERTY('ServerName') AS &#91;Instance],<br>&nbsp;&nbsp; reqs.session_id,<br>&nbsp;&nbsp; sess.login_name,<br>&nbsp;&nbsp; reqs.command,<br>&nbsp;&nbsp; CAST(reqs.percent_complete AS NUMERIC(10, 2)) AS &#91;Percent Complete],<br>&nbsp;&nbsp; CONVERT(VARCHAR(20), DATEADD(ms, reqs.estimated_completion_time, GETDATE()), 20) AS &#91;Estimated Completion Time],<br>&nbsp;&nbsp; CAST(reqs.total_elapsed_time / 60000.0 AS NUMERIC(10, 2)) AS &#91;Elapsed Minutes],<br>&nbsp;&nbsp; CAST(reqs.estimated_completion_time / 60000.0 AS NUMERIC(10, 2)) AS &#91;Estimated Remaining Time in Minutes],<br>&nbsp;&nbsp; CAST(reqs.estimated_completion_time / 3600000.0 AS NUMERIC(10, 2)) AS &#91;Estimated Remaining Time in Hours],<br>&nbsp;&nbsp; CAST((<br>&nbsp;&nbsp;&nbsp;&nbsp; SELECT SUBSTRING(text, reqs.statement_start_offset/2,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CASE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHEN reqs.statement_end_offset = -1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; THEN 1000<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ELSE(reqs.statement_end_offset-reqs.statement_start_offset)/2<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; END)<br>&nbsp;&nbsp;&nbsp;&nbsp; FROM sys.dm_exec_sql_text(sql_handle)) AS VARCHAR(1000)) AS &#91;SQL]<br>FROM sys.dm_exec_requests AS reqs<br>&nbsp;JOIN sys.dm_exec_sessions AS sess ON sess.session_id = reqs.session_id<br>WHERE command IN('RESTORE DATABASE', 'BACKUP DATABASE');</code></pre>



<p>The script returns the following information:</p>



<ul class="wp-block-list">
<li>Instance Name</li>



<li>Session Id&nbsp;</li>



<li>Login Name</li>



<li>Command&nbsp;</li>



<li>Percent Complete</li>



<li>Estimated Completion Time</li>



<li>Elapsed Time in Minutes</li>



<li>Estimated Remaining Time in Minutes</li>



<li>Estimated Remaining Time in Hours</li>



<li>The Complete Command Used to Start Backup/Restore<br></li>
</ul>



<p>Since this script uses Dynamic Management Views, it won&#8217;t work on ancient versions of SQL Server. I&#8217;ve tested it on SQL Server 2008 R2 and forward on the Windows version. I haven&#8217;t tried it on SQL Server 2017 running on Linux.&nbsp;</p>



<p>Hopefully, you&#8217;ll find this script handy. Here are a few more that you may find helpful.</p>



<ul class="wp-block-list">
<li><a href="https://theserogroup.com/sql-server/hadr-options-for-sql-server/">High Availability and Disaster Recovery in SQL Server</a></li>



<li><a href="https://theserogroup.com/sql-server/how-to-create-sql-server-2019-failover-clustered-instances-in-azure/">How to Create SQL Server 2019 Failover Clustered Instances in Azure</a></li>



<li><a href="https://theserogroup.com/sql-server/vollgar-6-scripts-to-help-review-your-sql-servers/">Vollgar: 6 Scripts to Help Review Your SQL Servers</a></li>
</ul>



<h2 class="wp-block-heading" id="h-want-to-work-with-the-sero-group">Want to work with The Sero Group?</h2>



<p>Want to learn more about how SERO Group helps organizations take the guesswork out of managing their SQL Servers? It’s easy and there is no obligation.&nbsp;</p>



<p><a href="https://theserogroup.com/#contact" target="_blank" rel="noreferrer noopener">Schedule a call</a> with us to get started.</p>
<p>The post <a href="https://theserogroup.com/sql-server/script-how-long-until-my-sql-server-backup-restore-completes/">Script: How Long Until My SQL Server Backup/Restore Completes?</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theserogroup.com/sql-server/script-how-long-until-my-sql-server-backup-restore-completes/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2269</post-id>	</item>
	</channel>
</rss>
