<?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>DBA Archives - The SERO Group</title>
	<atom:link href="https://theserogroup.com/tag/dba/feed/" rel="self" type="application/rss+xml" />
	<link>https://theserogroup.com/tag/dba/</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>DBA Archives - The SERO Group</title>
	<link>https://theserogroup.com/tag/dba/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">121220030</site>	<item>
		<title>Identify Disk I/O Performance Issues for Your SQL Server Using DiskSpd</title>
		<link>https://theserogroup.com/sql-server-consulting/identify-disk-i-o-performance-issues-for-your-sql-server-using-diskspd/</link>
					<comments>https://theserogroup.com/sql-server-consulting/identify-disk-i-o-performance-issues-for-your-sql-server-using-diskspd/#comments</comments>
		
		<dc:creator><![CDATA[Joe Webb]]></dc:creator>
		<pubDate>Wed, 21 Oct 2020 15:04:21 +0000</pubDate>
				<category><![CDATA[SQL Server Consulting]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[IT Manager]]></category>
		<category><![CDATA[Script Library]]></category>
		<category><![CDATA[Shared Disks]]></category>
		<category><![CDATA[SQL Assessment]]></category>
		<category><![CDATA[SQL Audit]]></category>
		<category><![CDATA[SQL Consulting]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Management]]></category>
		<category><![CDATA[Video]]></category>
		<guid isPermaLink="false">https://theserogroup.com/?p=3245</guid>

					<description><![CDATA[<p>&#8220;We need faster storage.” Sound familiar? Or what about &#8220;No, the storage is good; we need to tune the database.&#8221; Often teams will have very different opinions about the root cause of a performance issue. Microsoft&#8217;s free DiskSpd utility can help identify disk I/O performance issues for your SQL server systems. Here&#8217;s a short introduction&#8230; <br /> <a class="read-more" href="https://theserogroup.com/sql-server-consulting/identify-disk-i-o-performance-issues-for-your-sql-server-using-diskspd/">Read more</a></p>
<p>The post <a href="https://theserogroup.com/sql-server-consulting/identify-disk-i-o-performance-issues-for-your-sql-server-using-diskspd/">Identify Disk I/O Performance Issues for Your SQL Server Using DiskSpd</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>&#8220;We need faster storage.” Sound familiar? Or what about &#8220;No, the storage is good; we need to tune the database.&#8221; Often teams will have very different opinions about the root cause of a performance issue. Microsoft&#8217;s free DiskSpd utility can help identify disk I/O performance issues for your SQL server systems. </p>



<p>Here&#8217;s a short introduction video for how DiskSpd can be used to gather the necessary performance metrics without using the SQL Server Dynamic Management Views (DMVs). Having a way to support your case without using SQL Server to capture these metrics can sometimes be helpful. </p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<div class='embed-container'><iframe title="DiskSpd Can Help Identify Disk I/O Performance Issues for Your SQL Server Systems" width="1920" height="1080" src="https://www.youtube.com/embed/_fkYltxe6tc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
</div></figure>



<h3 class="wp-block-heading">Using DiskSpd on Your SQL Server System</h3>



<p>Using Diskspd we can benchmark the raw performance of storage without relying on SQL Server DMV information at all. It’ll report on write and read latency, on sequential and random disk activity. It’s very granular and can be extremely insightful.</p>



<p>For example, I downloaded the utility and ran it on my laptop using the following command. </p>



<pre class="wp-block-code"><code>Diskspd.exe -b8K -d60 -h -L -o2 -t4 -r -w30 -c100M c:\test\io.dat > c:\test\output.txt</code></pre>



<p>In this simple case, I set the block size to 8K using the -b parameter, ran the test for 60 seconds using the -d parameter, disabled hardware and software caching with the -h parameter, measured latency statistics with -L, used 2 overlapped IOs with the -o parameter, created 4 threads per target with the -t parameter, defined a workload of random input/output with the -r parameter, defined 30% of the I/O to be writes with the -w parameter, had the utility create a 100MB test file at c:\test\io.dat, and configured the output to be written to c:\test\output.txt. </p>



<p>There are many more parameters available in DiskSpd. For a complete list, run DiskSpd -?. </p>



<h3 class="wp-block-heading">Interpreting the DiskSpd Disk I/O Performance Results</h3>



<p>In my case, I received the following results in the c:\test\output.txt file. Keep in mind this is on a laptop and not a production SQL Server. </p>



<pre class="wp-block-code"><code>
Command Line: Diskspd.exe -b8K -d60 -h -L -o2 -t4 -r -w30 -c100M c:\test\io.dat

Input parameters:

	timespan:   1
	-------------
	duration: 60s
	warm up time: 5s
	cool down time: 0s
	measuring latency
	random seed: 0
	path: 'c:\test\io.dat'
		think time: 0ms
		burst size: 0
		software cache disabled
		hardware write cache disabled, writethrough on
		performing mix test (read/write ratio: 70/30)
		block size: 8192
		using random I/O (alignment: 8192)
		number of outstanding I/O operations: 2
		thread stride size: 0
		threads per file: 4
		using I/O Completion Ports
		IO priority: normal

System information:

	computer name: DESKTOP-K9DJS56
	start time: 2020/10/21 14:18:01 UTC

Results for timespan 1:
*******************************************************************************

actual test time:	60.00s
thread count:		4
proc count:		4

CPU |  Usage |  User  |  Kernel |  Idle
-------------------------------------------
   0|  71.35%|  13.26%|   58.10%|  28.65%
   1|  66.28%|  15.23%|   51.04%|  33.72%
   2|  70.03%|  13.41%|   56.61%|  29.97%
   3|  68.15%|  17.73%|   50.42%|  31.85%
-------------------------------------------
avg.|  68.95%|  14.91%|   54.04%|  31.05%

Total IO
thread |       bytes     |     I/Os     |    MiB/s   |  I/O per s |  AvgLat  | LatStdDev |  file
-----------------------------------------------------------------------------------------------------
     0 |      4398579712 |       536936 |      69.91 |    8948.90 |    0.222 |     0.740 | c:\test\io.dat (100MiB)
     1 |      4435599360 |       541455 |      70.50 |    9024.22 |    0.221 |     0.739 | c:\test\io.dat (100MiB)
     2 |      4433772544 |       541232 |      70.47 |    9020.50 |    0.221 |     0.757 | c:\test\io.dat (100MiB)
     3 |      4367548416 |       533148 |      69.42 |    8885.77 |    0.224 |     0.787 | c:\test\io.dat (100MiB)
-----------------------------------------------------------------------------------------------------
total:       17635500032 |      2152771 |     280.31 |   35879.40 |    0.222 |     0.756

Read IO
thread |       bytes     |     I/Os     |    MiB/s   |  I/O per s |  AvgLat  | LatStdDev |  file
-----------------------------------------------------------------------------------------------------
     0 |      3077742592 |       375701 |      48.92 |    6261.66 |    0.256 |     0.669 | c:\test\io.dat (100MiB)
     1 |      3101097984 |       378552 |      49.29 |    6309.18 |    0.256 |     0.751 | c:\test\io.dat (100MiB)
     2 |      3100819456 |       378518 |      49.29 |    6308.61 |    0.254 |     0.606 | c:\test\io.dat (100MiB)
     3 |      3055476736 |       372983 |      48.57 |    6216.36 |    0.258 |     0.715 | c:\test\io.dat (100MiB)
-----------------------------------------------------------------------------------------------------
total:       12335136768 |      1505754 |     196.06 |   25095.82 |    0.256 |     0.688

Write IO
thread |       bytes     |     I/Os     |    MiB/s   |  I/O per s |  AvgLat  | LatStdDev |  file
-----------------------------------------------------------------------------------------------------
     0 |      1320837120 |       161235 |      20.99 |    2687.24 |    0.144 |     0.879 | c:\test\io.dat (100MiB)
     1 |      1334501376 |       162903 |      21.21 |    2715.04 |    0.139 |     0.702 | c:\test\io.dat (100MiB)
     2 |      1332953088 |       162714 |      21.19 |    2711.89 |    0.144 |     1.023 | c:\test\io.dat (100MiB)
     3 |      1312071680 |       160165 |      20.85 |    2669.41 |    0.145 |     0.928 | c:\test\io.dat (100MiB)
-----------------------------------------------------------------------------------------------------
total:        5300363264 |       647017 |      84.25 |   10783.58 |    0.143 |     0.890



total:
  %-ile |  Read (ms) | Write (ms) | Total (ms)
----------------------------------------------
    min |      0.054 |      0.048 |      0.048
   25th |      0.168 |      0.082 |      0.121
   50th |      0.192 |      0.095 |      0.174
   75th |      0.228 |      0.113 |      0.211
   90th |      0.337 |      0.144 |      0.292
   95th |      0.557 |      0.203 |      0.454
   99th |      1.394 |      0.610 |      1.291
3-nines |      4.510 |     14.778 |      5.577
4-nines |     18.031 |     26.059 |     20.629
5-nines |    117.426 |    117.574 |    117.502
6-nines |    153.091 |    161.708 |    153.091
7-nines |    162.048 |    161.708 |    162.048
8-nines |    162.048 |    161.708 |    162.048
9-nines |    162.048 |    161.708 |    162.048
    max |    162.048 |    161.708 |    162.048
</code></pre>



<p>As you can see, DiskSpd creates quite a bit of information.</p>



<p>According to the results, the test consumed nearly 69% of the CPU resources. As for the latency, the last section shows the metrics broken down by percentiles. In my case, the minimum read latency was 0.054 ms and the best write latency I could achieve was 0.048 ms. The maximum latencies were read 162.048 ms and write 161.708 ms. At the 50th percentile, my system had a read latency of 0.192 ms and a write latency of 0.095 ms.</p>



<p>This output can help you determine whether the disk I/O subsystem is delivering the performance your SQL Server system needs.</p>



<h3 class="wp-block-heading">Where to Get DiskSpd</h3>



<p>DiskSpd is available on <a href="https://github.com/microsoft/diskspd" target="_blank" rel="noreferrer noopener">GitHub</a>, and additional how-to documentation can be found on TechNet <a href="https://gallery.technet.microsoft.com/DiskSpd-a-robust-storage-6cd2f223" target="_blank" rel="noreferrer noopener">here</a>. </p>



<p>For other checks to run on your SQL Server system, check out <a href="https://theserogroup.com/2019/08/06/is-my-sql-server-configured-properly/">Is My SQL Server Configured Properly</a>.</p>
<p>The post <a href="https://theserogroup.com/sql-server-consulting/identify-disk-i-o-performance-issues-for-your-sql-server-using-diskspd/">Identify Disk I/O Performance Issues for Your SQL Server Using DiskSpd</a> appeared first on <a href="https://theserogroup.com">The SERO Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://theserogroup.com/sql-server-consulting/identify-disk-i-o-performance-issues-for-your-sql-server-using-diskspd/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3245</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 fetchpriority="high" 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="(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>
