<?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>Mike Tutor, Author at SQL Solutions Group</title>
	<atom:link href="https://sqlsolutionsgroup.com/author/mtutor/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlsolutionsgroup.com/author/mtutor/</link>
	<description></description>
	<lastBuildDate>Tue, 07 Jul 2026 23:05:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.3</generator>

<image>
	<url>https://sqlsolutionsgroup.com/wp-content/uploads/2021/01/cropped-SSG_FAVICON0002-32x32.png</url>
	<title>Mike Tutor, Author at SQL Solutions Group</title>
	<link>https://sqlsolutionsgroup.com/author/mtutor/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>A Faster Way to Migrate SQL Server Instances!</title>
		<link>https://sqlsolutionsgroup.com/migrate-sql-server/</link>
					<comments>https://sqlsolutionsgroup.com/migrate-sql-server/#comments</comments>
		
		<dc:creator><![CDATA[Mike Tutor]]></dc:creator>
		<pubDate>Thu, 09 Jul 2020 11:47:00 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[sql server migration]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=2068</guid>

					<description><![CDATA[<p>I have had to migrate SQL Server instances many times over the years. Sometimes as part of an upgrade from one version to another, and other times just to move to new/bigger better hardware. In my current situation, the client wants to virtualize all of their SQL Server instances. Most of their database servers are already virtualized, [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/migrate-sql-server/">A Faster Way to Migrate SQL Server Instances!</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">I have had to migrate SQL Server instances many times over the years. Sometimes as part of an upgrade from one version to another, and other times just to move to new/bigger better hardware. In my current situation, the client wants to virtualize all of their SQL Server instances. Most of their database servers are already virtualized, but there are still four or five stragglers and they have set a deadline to get the rest moved. The first instance to be moved (because it is older hardware) is a SQL Server 2008 instance. We want to upgrade it to SQL Server 2008 R2 since all but one other instance are already on R2 or 2012. So how best to proceed?</p>



<div class="wp-block-image">
<figure class="aligncenter"><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2015/02/migrate.jpg"><img fetchpriority="high" decoding="async" width="850" height="392" class="wp-image-4643" src="https://sqlsolutionsgroup.com/wp-content/uploads/2015/02/migrate.jpg" alt="migrate sql server" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2015/02/migrate.jpg 850w, https://sqlsolutionsgroup.com/wp-content/uploads/2015/02/migrate-300x138.jpg 300w, https://sqlsolutionsgroup.com/wp-content/uploads/2015/02/migrate-768x354.jpg 768w" sizes="(max-width: 850px) 100vw, 850px" /></a></figure>
</div>



<h3 class="wp-block-heading">Don&#8217;t Upgrade In Place</h3>



<p class="wp-block-paragraph">I briefly considered doing an in-place upgrade. But as I have never done one before, I thought that just maybe an upgrade from 2008 to 2008 R2 would be simple enough to give it a go. I did some reading and talked with my MCM colleagues at SQL Solutions Group (SSG) and the recommendation was unanimous: Don’t do an in-place upgrade.</p>



<p class="wp-block-paragraph">If for any reason the upgrade fails, you may be left with an instance that won’t come on-line and the rollback is arduous. If the upgrade fails, your best recourse is to restore your system from a full system state backup. Often an upgrade will make changes to the system databases so a restore is in order there as well. As with all the options discussed herein, planning for all contingencies is paramount. <strong>Upgrading in place is tempting, but just don’t do it.</strong></p>


<hr class="wp-block-separator" />


<p class="has-text-align-center" style="font-size: 20px;">How could a remote DBA managed service from</p>
<p class="has-text-align-center" style="font-size: 20px;">SQL Solutions Group free up technical personnel to</p>
<p class="has-text-align-center" style="font-size: 20px;">focus on bottom-line projects that impact ROI? <span style="text-decoration: underline;"><a href="https://sqlsolutionsgroup.com/services/remote-dba-services/" target="_blank" rel="noreferrer noopener" aria-label="undefined (opens in a new tab)">Find out</a></span>. </p>


<hr class="wp-block-separator" />


<p class="wp-block-paragraph">So, that left me with choosing from one of the ‘industry standard methodologies’ to migrate SQL Server instances. Which methodology to use is often a matter of preference and/or your specific circumstances.</p>



<h3 class="wp-block-heading"><strong><span style="text-decoration: underline;">Methodology #1</span></strong></h3>



<p class="wp-block-paragraph">Stop access to the source database server, then backup all the databases and copy the full backups to the target and restore them there. This is an easy way to go if you have the downtime. If you have a large amount of data, however, the time becomes prohibitive. You must back up the databases, copy the backups over to the new server, and then restore the databases thereon. Any one or all of these steps can takes hours. I have performed this method successfully several times, but my total data space for all the databases was under 100 GB.</p>



<h3 class="wp-block-heading"><strong><span style="text-decoration: underline;">Methodology #2</span></strong></h3>



<p class="wp-block-paragraph">Stop access to the source database server, detach the databases from the source and attach them to the target. Similar to methodology #1, this is easy if you have the downtime. You detach the databases on the source, copy the .ldfs and .mdfs to the target and reattach. Detaching and attaching the databases is much quicker than backup and restore. But, your copy of the files will take longer since you lose the compression you get with the backups.</p>



<h3 class="wp-block-heading"><strong><span style="text-decoration: underline;">Methodology #3</span></strong></h3>



<p class="wp-block-paragraph">Take one last full backup of all the databases on the source instance and recover them to the target using NORECOVERY. It is important that these are <strong>the last full backups</strong> since the intent is to complete the recovery using the DIFF backups. If you must create another full backup, make sure to use the &#8216;copy only&#8217; option so as not to break the backup chain. <strong><span style="text-decoration: underline;">Do not</span></strong> stop access to the source database during this portion of the migration. When it is time to perform the migration, stop access to the databases and take DIFF backups on the source server and restore the DIFFs on the target. This greatly minimizes the downtime compared to methodologies #1 and #2 because the DIFF backups will be a fraction of the size of the full backups.</p>



<h3 class="wp-block-heading"><strong><span style="text-decoration: underline;">Methodology #4</span></strong></h3>



<p class="wp-block-paragraph">Setup log shipping from the source to the target, and then make the target the master and stop the log shipping. This offers the least amount of downtime but is also the most amount of setup time. To be honest, I have never migrated a server this way, but I know people have done it.</p>



<p class="wp-block-paragraph">So those were my options when I started preparing to upgrade the 2008 server to 2008 R2. I immediately eliminated methods 1 and 2 because the amount of data was much larger than the downtime window would permit. Since this is an upgrade, Method 4 would not work as the source and target instances need to be of the same version of SQL Server. My choice was pretty obvious, the only option left was method 3…or so I thought.</p>



<p class="wp-block-paragraph">I was working with the system admins to build the virtual machine that was to become the ‘target’ database server when <strong><span style="text-decoration: underline;">Methodology #5</span></strong> popped into my head:</p>



<h3 class="wp-block-heading"><span style="color: #f25e00;"><strong><span style="text-decoration: underline;">Methodology #5</span></strong></span></h3>



<p class="wp-block-paragraph">Shutdown SQL Server on the source instance, move the LUNs from the old server to the new server and attach the databases there. Fast and easy with little downtime if you have done all your setup properly prior to this step (of course). This only works if you are using a SAN and the new database server is on the same SAN.</p>



<p class="wp-block-paragraph">Maybe this is not a new idea but it was new to me. In all the ‘How To Migrate a SQL Server Instance…’ articles I have read, not one of them mentioned this methodology as an option. I am sure I am not the first to come up with this plan, but it was nothing short of a revelation for me.</p>



<p class="wp-block-paragraph"><strong>Author&#8217;s note</strong>: I have since talked to other seasoned professionals, and methodology #5 is not a <em>new</em> idea. No surprise there, but it was new to me. I figured that makes it worth blogging about, since maybe it is new to you! 🙂</p>



<p class="wp-block-paragraph">So, what is involved in preparing the target server for the migration?<strong> </strong></p>



<h3 class="wp-block-heading"><strong>Migration Considerations</strong></h3>



<p class="wp-block-paragraph">Migrate the system databases? If you are not doing an upgrade to a different version of SQL Server, you may choose to copy the system databases from the source server to the target. It is a matter of personal preference whether to copy the system databases or to create them anew. I have heard arguments for and against both options. Regardless, this is not an option in my scenario so I will not delve into that here. A reasonably good step-by-step can be found <a href="https://yrushka.com/index.php/database-recovery/sql-server-migration-from-one-server-to-another-detailed-checklist/">here</a>.</p>



<p class="wp-block-paragraph">So, since we are not migrating the system databases, we must make sure that we copy all the pertinent objects from the source system databases to the new.</p>



<h4 class="wp-block-heading"><strong>Create the new server</strong></h4>



<p class="wp-block-paragraph">Create the new server with the same disk configuration as the old one. This is not required and may not be viable, but it is much easier if you can stick with the old configuration. You will have to alter your attach script to reflect the new configuration.</p>



<h4 class="wp-block-heading"><strong>Move the new system databases</strong></h4>



<p class="wp-block-paragraph">Move the new system databases where you want them to reside in the future if you did not create them there during installation. They do not have to reside in the same location as the old ones. If they are on the same drives as your databases, make sure to have a copy of the .mdf and .ldf for each so you can move them back into place once you attach the new LUNs.</p>



<h4 class="wp-block-heading"><strong>Recreate logins</strong></h4>



<p class="wp-block-paragraph">There are numerous tools for this process, but the oldest way to do it is to use sp_help_revlogin. This stored procedure provided by Microsoft for this very purpose has been around since SQL Server 7 (possibly 6.5?) and is still used today. It copies all the logins and passwords and recreates them with the same SID they had on the old machine. <a href="https://support.microsoft.com/kb/918992">Here is the Microsoft support page</a>.</p>



<p class="wp-block-paragraph"><strong>Copy the following</strong> by scripting them out on the old instance:</p>



<ul class="wp-block-list">
<li><strong>User defined Stored Procedures and Functions</strong> in master. You may possibly have some in model and msdb, so make sure to check and script those as well if needed.</li>
<li><strong>Permissions on system databases. </strong>This is often overlooked, but don’t forget that you may have specific permissions granted on some or all of the stored procedures and functions.</li>
<li><strong>Linked Servers.</strong> Script these out on the old server and recreate them on the new. Remember that scripting of linked servers will not script the passwords. You will need to obtain these and put them in the script manually.</li>
<li>The easiest way (in my opinion) to do this is to within SSMS. Simply highlight the jobs you want to move over (ctrl-A if you want them all) and right click on the top one and select ‘Script Job as…’</li>
<li><strong>DB Mail.</strong> Make sure to write down your DB Mail settings on the old server so you can activate it on the new server. (Again, the Microsoft technet page is above&#8230;and <a href="https://support.microsoft.com/kb/918992">here</a> for convenience).</li>
</ul>



<p class="wp-block-paragraph">Or if you like some scripts for DB Mail, <a href="https://www.sqlservercentral.com/Forums/Topic982618-391-1.aspx">go here</a>.</p>



<h4 class="wp-block-heading"><strong>Create a script </strong></h4>



<p class="wp-block-paragraph"><strong>Create a script for attaching all the databases</strong> on the new server. Here is a script I wrote for creating an attach script. It assumes that the databases will be in the same location as they were on the old server. Run this on the old server (in text mode) and it will create the attach script.</p>



<h3 class="wp-block-heading">Follow The Script</h3>


<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">USE</span> master; GO <span class="kw1">SET</span> <span class="kw1">NOCOUNT</span> <span class="kw1">ON</span> <span class="kw1">IF</span> <span class="kw2">OBJECT_ID</span><span class="br0">&#40;</span> <span class="st0">'tempdb.dbo.#tmp'</span> <span class="br0">&#41;</span> <span class="kw1">IS</span> <span class="sy0">NOT</span> <span class="sy0">NULL</span> <span class="kw1">DROP</span> <span class="kw1">TABLE</span> #tmp; <span class="kw1">DECLARE</span> @SQLcmd <span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="kw2">MAX</span><span class="br0">&#41;</span> ,@DatabaseName <span class="kw1">VARCHAR</span><span class="br0">&#40;</span>255<span class="br0">&#41;</span> ,@PrevDatabaseName <span class="kw1">VARCHAR</span><span class="br0">&#40;</span>255<span class="br0">&#41;</span>; <span class="kw1">SET</span> @SQLcmd <span class="sy0">=</span> <span class="st0">''</span>; <span class="kw1">SET</span> @DatabaseName <span class="sy0">=</span> <span class="st0">';'</span>; <span class="kw1">SET</span> @PrevDatabaseName <span class="sy0">=</span> <span class="st0">''</span>; <span class="kw1">CREATE</span> <span class="kw1">TABLE</span> #tmp <span class="br0">&#40;</span> DatabaseName SYSNAME <span class="sy0">NULL</span> ,FileId <span class="kw1">INT</span> <span class="sy0">NULL</span> ,FileName <span class="kw1">VARCHAR</span><span class="br0">&#40;</span>2000<span class="br0">&#41;</span> <span class="sy0">NULL</span> ,SQLcmd <span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="kw2">MAX</span><span class="br0">&#41;</span> <span class="sy0">NULL</span> <span class="br0">&#41;</span>; <span class="kw1">INSERT</span>  <span class="kw1">INTO</span> #tmp <span class="kw1">SELECT</span> <span class="kw1">DISTINCT</span> <span class="kw2">DB_NAME</span><span class="br0">&#40;</span>dbid<span class="br0">&#41;</span> <span class="kw1">AS</span> DatabaseName ,FileId ,FileName ,<span class="kw1">CONVERT</span><span class="br0">&#40;</span><span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="kw2">MAX</span><span class="br0">&#41;</span>, <span class="st0">''</span><span class="br0">&#41;</span> <span class="kw1">AS</span> SQLcmd <span class="kw1">FROM</span> master.<span class="me1">dbo</span>.<span class="me1">sysaltfiles</span> <span class="kw1">WHERE</span> dbid <span class="sy0">IN</span> <span class="br0">&#40;</span> <span class="kw1">SELECT</span> dbid <span class="kw1">FROM</span> master.<span class="me1">dbo</span>.<span class="me1">sysaltfiles</span> <span class="kw1">WHERE</span> <span class="kw2">SUBSTRING</span><span class="br0">&#40;</span>FileName, <span class="nu0">1</span>, <span class="nu0">1</span><span class="br0">&#41;</span> <span class="sy0">IN</span> <span class="br0">&#40;</span> <span class="st0">'G'</span>, <span class="st0">'F'</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span>  <span class="co1">-- Put the appropriate drives here --AND DATABASEPROPERTYEX(DB_NAME(dbid), 'Status') = 'ONLINE' AND DB_NAME(dbid) NOT IN ( 'master', 'model', 'msdb', 'tempdb', 'ditribution' ) ORDER BY DatabaseName, FileId, FileName; UPDATE #tmp SET @SQLcmd = SQLcmd = CASE WHEN DatabaseName &lt;&gt; @PrevDatabaseName THEN CONVERT(VARCHAR(200), 'exec sp_attach_db @DBName = N''' + DatabaseName + '''') ELSE @SQLcmd END + ',@FileName' + CONVERT(VARCHAR(10), FileId) + '=N''' + FileName + '''' ,@PrevDatabaseName = CASE WHEN DatabaseName &lt;&gt; @PrevDatabaseName THEN DatabaseName ELSE @PrevDatabaseName END ,@DatabaseName = DatabaseName FROM #tmp; SELECT 'USE master;' + CHAR(13) + CHAR(10) + 'GO' SELECT SQLcmd FROM ( SELECT DatabaseName, MAX(SQLcmd) AS SQLcmd FROM #tmp GROUP BY DatabaseName ) AS SQLcmd; --DROP TABLE #tmp GO</span></pre></div></div>



<p class="wp-block-paragraph">If you plan on moving the databases to different drives you can easily modify this script to change the attach location.</p>



<h3 class="wp-block-heading"><strong>One Last Important Consideration</strong></h3>



<p class="wp-block-paragraph">When the mdfs and ldfs are connected to the new database instance, they will be upgraded to the new version. This action cannot be undone. If a rollback situation occurs, you cannot simply move the LUNs back to the old server and reattach. Your only option here is to restore the databases you took prior to the upgrade. <strong>Before you begin the actual migration, </strong>create and save final backups of the databases on the old server.</p>



<p class="wp-block-paragraph">I suggest you make a FULL backup of all the databases several hours before you block access to the SQL Server instance. As with methodology #3 above, make sure these are the last full backups taken. Then make one last DIFF backup and save them all (fulls and diffs) in a safe place. It is probably a good idea to have a restore script for all the databases pre-defined so that you are not scrambling to recover if this scenario presents itself. Keep in mind that any transactions incurred on the new server will be lost unless you take steps to find the data differences and import them back.</p>



<p class="wp-block-paragraph"><a href="https://youtu.be/Otm4RusESNU">That’s all I have to say about that. </a>This is by no means a complete step-by-step plan to migrate SQL Server, but hopefully it helps in your quest for the seamless migration.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/migrate-sql-server/">A Faster Way to Migrate SQL Server Instances!</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/migrate-sql-server/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>What is a DBA Worth?</title>
		<link>https://sqlsolutionsgroup.com/what-is-a-dba-worth/</link>
					<comments>https://sqlsolutionsgroup.com/what-is-a-dba-worth/#comments</comments>
		
		<dc:creator><![CDATA[Mike Tutor]]></dc:creator>
		<pubDate>Tue, 31 Mar 2015 06:16:46 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[consulting]]></category>
		<category><![CDATA[DBA]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=2194</guid>

					<description><![CDATA[<p>The value of a DBA can vary depending on numerous factors. Something that should be easy to answer is: what is a DBA worth? If you follow industry trends at all, or if you have been in the situation where you were attempting to hire an experienced DBA, you no doubt are aware of the [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/what-is-a-dba-worth/">What is a DBA Worth?</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The value of a DBA can vary depending on numerous factors. Something that should be easy to answer is: what is a DBA worth?</p>
<p>If you follow industry trends at all, or if you have been in the situation where you were attempting to hire an experienced DBA, you no doubt are aware of the shortage of qualified DBAs. If not, take a look at these articles: <a href="https://www.dbta.com/Columns/SQL-Server-Drill-Down/IT-Employers-Must-Adapt-to-the-Looming-DBA-Shortage-102621.aspx">Looming DBA Shortage</a> and <a href="https://www.computerweekly.com/feature/DBAs-and-data-warehouse-architects-in-high-demand">DBAs in high demand</a>. The statistic that really caught my eye was in this article, <a href="https://www.careerbuilder.com/advice/top-job-database-administrators">Why DBAs are in Demand</a> from <em>careerbuilder.com</em>, which states, &#8220;there are only 14 active candidates for every 100 jobs posted.”</p>
<p>If that doesn&#8217;t denote a shortage, I don’t know what does. That leads to an essential question: What is a DBA worth? A shortage like this would tend to give candidates an incredible amount of leverage, and skew salaries higher.</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2015/03/DBAworth.jpg"><img decoding="async" class="aligncenter size-full wp-image-4630" src="https://sqlsolutionsgroup.com/wp-content/uploads/2015/03/DBAworth.jpg" alt="what is a DBA worth" width="850" height="567" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2015/03/DBAworth.jpg 850w, https://sqlsolutionsgroup.com/wp-content/uploads/2015/03/DBAworth-300x200.jpg 300w, https://sqlsolutionsgroup.com/wp-content/uploads/2015/03/DBAworth-768x512.jpg 768w" sizes="(max-width: 850px) 100vw, 850px" /></a></p>
<p>So I was perplexed by a situation that I recently witnessed first-hand at one of my clients. This particular client has been looking to fill two DBA positions (one senior and one intermediate level) for more than six months. They identified a really good senior candidate who wanted the job. I know she was <strong><em>very good</em></strong> because I was involved in the interview process. All they had to do was make her a decent offer and she’d be in. It didn’t happen. While I am saddened that they wouldn’t meet her salary requirement (a reasonable number, all things considered), I am glad she stuck to her guns and didn’t take less than she was worth.</p>
<p>To further confuse their decision not to hire her over a difference of a few thousand dollars, consider this client’s history with DBAs. They’ve had a string of poor to bad DBAs over the last several years. Most recently (six months ago) they had two DBAs I will call Clueless-Inexperienced DBA and Lazy-I’m-too-good-for-this place DBA. Clueless DBA was fired after repeated lapses in judgement that caused large amounts of data loss, and Lazy DBA quit shortly thereafter knowing that she was on the verge of being fired herself.</p>
<p>So along comes the new candidate I’ll call Quality DBA with 10+ years of experience in SQL Server and a proven history of success. And what does the hiring organization do? They let Quality DBA walk because of salary.</p>
<p>Consider this as well: I have been working as the DBA at this client since the demise of Clueless and Lazy, and I have spent a great deal of time fixing this, tweaking that, tuning all of the above, and generally doing all of those things that a DBA is supposed to do. Current status: All the systems are stabilized; all the jobs complete every night; user requests are completed in a timely fashion. None of those things were true before, and I am only contracted for 30 hours a week. Am I some kind of superhero DBA?</p>
<p>I wish. No, I am just a trained, experienced DBA doing what a good DBA is supposed to do. I discussed this with the client and they agreed: I convinced them that what they needed was one really good Sr. DBA rather than two less-than-good DBAs. So… big savings AND a stable, well-managed environment if they would just hire Quality DBA. Slam dunk right? Nope! Arrgh!</p>
<p>I have no statistics to back it up, and I haven’t performed an extensive study, but my personal experience tells me this kind of shortsightedness is happening at many companies around the country (U.S.) and perhaps the world.</p>
<p>So the question that comes up is: <strong>Why is this happening?</strong></p>
<p>In my opinion, this is happening because:</p>
<ul>
<li>There are people outside of the IT department, namely the Human Resources Department (HR), making salary decisions based on market averages.</li>
<li>The “market averages” are inconsistent and confusing. I researched averages in my local area and found numbers for a DBA ranging from $80K to $115K (salary.com, indeed.com). Unfortunately the decision makers will see $80K and decide to use that number, or perhaps go even lower.</li>
<li>The &#8220;market average&#8221; salaries are for &#8220;average&#8221; employees. In the situation above, they had two average DBAs making average DBA wages, when all they need is one good DBA.</li>
<li>To further that thought, DBAs are not doing a good enough job of selling themselves. HR says, &#8220;The average salary is&#8230;&#8221;. The DBA should reply &#8220;That&#8217;s for an average DBA. Is that really who you want securing your data? I&#8217;m not an average DBA, I can do a better job than that.&#8221;</li>
<li>IT managers don’t really understand what a DBA does or how important they are to the company. If they don’t know, how are they going to convince HR?</li>
<li>We as a community are not doing a good enough job of educating upper management as to what we do, why it matters, and helping define what a DBA is worth. We seem to be happiest when nobody knows what we are doing or why.</li>
</ul>
<p>These are my opinions and observations, and I am very interested to hear yours. Please reply with your thoughts and if you have any suggestions how we can all work to improve the situation, please tell us that too!</p>
<p>The post <a href="https://sqlsolutionsgroup.com/what-is-a-dba-worth/">What is a DBA Worth?</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/what-is-a-dba-worth/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Unplug Now! Is it Possible?</title>
		<link>https://sqlsolutionsgroup.com/unplug-now/</link>
					<comments>https://sqlsolutionsgroup.com/unplug-now/#comments</comments>
		
		<dc:creator><![CDATA[Mike Tutor]]></dc:creator>
		<pubDate>Tue, 30 Dec 2014 14:24:03 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<category><![CDATA[unplug]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=1959</guid>

					<description><![CDATA[<p>At this very moment, as I write this, I am visiting my daughter and my grand kids for Christmas. I am on “vacation.” I have been on vacation for a week, and will continue to be on vacation for another week. However, I have carried my phone with me the entire time, even while at [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/unplug-now/">Unplug Now! Is it Possible?</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>At this very moment, as I write this, I am visiting my daughter and my grand kids for Christmas. I am on “vacation.” I have been on vacation for a week, and will continue to be on vacation for another week. However, I have carried my phone with me the entire time, even while at the movies. My phone notifies me of any incoming emails for three different accounts. During the last week I have also logged in to my client’s system and handled several different database issues. As a consultant, part of my job is to write blog posts periodically, so even writing this is work. The question is: am I <strong><em>really</em></strong> on vacation?</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/Tropical-Vacation.jpg"><img decoding="async" class="aligncenter size-large wp-image-1969" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/Tropical-Vacation-1024x576.jpg" alt="Unplug" width="669" height="376" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/Tropical-Vacation-1024x576.jpg 1024w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/Tropical-Vacation-300x169.jpg 300w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/Tropical-Vacation-768x432.jpg 768w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/Tropical-Vacation.jpg 1366w" sizes="(max-width: 669px) 100vw, 669px" /></a></p>
<h4 style="text-align: center;"><em><span style="font-family: 'trebuchet ms', geneva;"><strong>Could you unplug here?</strong></span></em></h4>
<p>I’m not complaining. Really, I’m not. I am enjoying my vacation despite the work interruptions. I might be whining a little bit (just a little), but I’ve made my own choices. I could easily get a job making less money at a place where little or no on-call is required. I’ve had jobs like that before. I also knew when I made the career choice to jump from developer to DBA that I was stepping into the wonderful world of IT support.</p>
<p>All that said, I still reflect on the best vacation I’ve ever had. I took an Alaskan cruise with my wife and kids. An hour after leaving port all signal to my phone was gone. It was long enough ago that there was no WiFi on the boat, so I was completely unplugged. I turned off my phone, put it in my suitcase, and for seven blissful days I was completely unencumbered with thoughts of work and other worldly concerns. It was reminiscent of the ‘70s. No pager, no mobile phone, no emails, no text messages, no Twitter, no Facebook. Talk to me when I get back. It was awesome.</p>
<p>There are thousands of articles (<span style="color: #f25e00;"><a style="color: #f25e00;" href="https://national.deseretnews.com/article/2169/7-benefits-of-taking-vacation-time.html">here is one</a></span>) on the Internet that discuss the mental, physical, creative, and regenerative benefits of an unplugged vacation, so I won’t regurgitate that here. But, <span style="color: #f25e00;"><a style="color: #f25e00;" href="https://www.traveleffect.com/research/overwhelmed-america">a survey by the U.S. Travel Association</a></span> found that 40% of Americans are not taking all the vacation time they earn. The survey says that there are many reasons for this, ranging from fear that they will be viewed as a less than dedicated employee to an over-inflated sense of self importance, a.k.a. “Nobody else can do what I do!” Unfortunately there are times when there is more truth to this than there should be.</p>
<p>For instance, I mentioned above that I worked on a client’s system this last week during my vacation. Well, this particular client had both of their DBAs leave the company in the last few months, and, as it turns out, I am actually the only person currently employed at the company who can do what I do. Also, many of us have had bosses who, whether they intend to or not, make you feel like you are being disloyal if you take the vacation that is your due.</p>
<p>So the question is: how do we—<span style="color: #f25e00;"><strong>the collective &#8220;we&#8221; known as IT support</strong></span>—unplug and take a <em><strong>real</strong></em> vacation? Can we? I believe the answer to this is <strong>yes, we can</strong>. However, we have to want it and we have to work at it. If we wait for the company we work for to make it happen, unless we work for a small number of progressively thinking companies (<span style="color: #f25e00;"><a style="color: #f25e00;" href="https://www.paperplanes.de/2014/12/10/from-open-to-minimum-vacation-policy.html">like this one</a></span>), it is not likely to happen.</p>
<p>Here are some suggestions that may help:</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong>Schedule your vacations well in advance</strong>. Let everyone know that not only will you be on vacation, but you will be mostly unavailable. Some may have heartburn over this, but stick to your guns as much as possible. Let them know it is important to you.</li>
<li><strong>Cross train</strong>: Make sure there is somebody else to do what you do when you are not there. We tend to have projects and/or responsibilities that are “ours.” We take ownership and we are often not very good at sharing. Get over it, give it up, and make sure somebody else at your organization can take it over. Sooner or later you’re going to move on and somebody else will have to take it anyway. If you are the sole DBA, see if you can get the company to train a system admin or two on basic DBA tasks like backups and disk space management. This will require documentation on your part.</li>
<li><strong>Talk to your boss</strong>: As hard as it may be to believe, your boss is a person too! Tell her your desire for some time completely away from your job. Don’t just start complaining and expect her to oblige; go to her with a plan. Show her it can work. Most bosses want you to be happy and will do what they can to work it out.</li>
<li><strong>Take small vacations</strong>: If it is wholly implausible for you to be unplugged for an entire week, try taking numerous three or four day weekends. You may still have to force the issue to make it happen, but if you can it will be easier to start extending these mini vacations into an entire week.</li>
<li><strong>Get lost</strong>: Take some vacations in the mountains, or in the desert, or… maybe the South Pole—some place where the answer to the question “Can you hear me now?” is “No.” This will force the issue. If they start talking about getting you a sat phone, look for another job.</li>
</ul>
</li>
</ul>
<p>I hope you find these suggestions helpful and if you are not already finding ways to unplug you can find a way to do so in the near future. I realize the realities of today’s working environment, but if you don’t give it your best shot, then you’ve got nobody to blame but yourself.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/unplug-now/">Unplug Now! Is it Possible?</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/unplug-now/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>T-SQL Tuesday #61– Giving Back!</title>
		<link>https://sqlsolutionsgroup.com/t-sql-tuesday-61-giving-back-2/</link>
		
		<dc:creator><![CDATA[Mike Tutor]]></dc:creator>
		<pubDate>Tue, 09 Dec 2014 23:11:55 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<category><![CDATA[T-SQL Tuesday]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=1859</guid>

					<description><![CDATA[<p>The subject for this T-SQL Tuesday is Giving Back. I have been a taker in the SQL community for many years. In 2012 I went to my first PASS Summit (you know, the year with the nice Ogio bags). I was duly impressed with the quality, quantity, and variety of presentations available for the attendees. I [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/t-sql-tuesday-61-giving-back-2/">T-SQL Tuesday #61– Giving Back!</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://blog.waynesheffield.com/wayne/archive/2014/12/t-sql-tuesday-61-giving-back/"><img loading="lazy" decoding="async" class="alignright wp-image-1860 size-full" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/TSQL2sDay150x150.jpg" alt="T-SQL Tuesday" width="154" height="154" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/TSQL2sDay150x150.jpg 154w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/TSQL2sDay150x150-150x150.jpg 150w" sizes="(max-width: 154px) 100vw, 154px" /></a></p>
<p>The subject for this T-SQL Tuesday is Giving Back. I have been a taker in the SQL community for many years.</p>
<p>In 2012 I went to my first PASS Summit (you know, the year with the nice Ogio bags). I was duly impressed with the quality, quantity, and variety of presentations available for the attendees. I learned so much that I was excited to get back to work (no really, I was excited) so I could implement some of the new things I had learned and fix some of the things I <em>thought</em> I was doing right.</p>
<p>Then I learned that everybody involved was <strong><em>volunteering their time</em></strong>. What? You mean, like, for free? I guess if you had asked me I would have said sure, people at conferences volunteer their time, but these sessions just didn’t feel like the drivel I usually had to endure at conferences. I felt like I had 3 days of awesome training tailored to my needs.</p>
<p>So, what to do? I realized that if all these people were willing to give of their time for my edification, shouldn&#8217;t I do the same for others (assuming I had anything worth giving)? How do I become a SQL evangelist like those that I now idolized? The answer was simple: Start small. I started by sharing my new-found knowledge and enthusiasm with my peers. I shared websites and scripts and…well, anything I could think of.</p>
<p>Then I found where and when the local PASS chapter was meeting and started attending regularly. After I felt comfortable in the group, I volunteered to present at some of the monthly chapter meetings. I was rough at first, but then I got better. This last year, I presented at four different SQL Saturdays, 1 local, and the rest out of state. I am finally giving back.</p>
<p>A watershed moment for me this past year was when a director from another department came over and gave me a hand-written note (with a little treat, yum!). The note said how much they appreciated my help and attention to detail, but what they appreciated the most was the mentoring that I provided. Wow! That stayed on my wall for months!</p>
<p>So what do I have planned for this next year? Well, to put it plainly, more, more, MORE of the same. I have already offered to help in the administration of the local PASS chapter (enthusiastically accepted). I also plan on volunteering to present at more SQLSaturdays this year (maybe 8?). My eventual ‘lofty’ goal is to present at PASS Summit, but I don’t want to get ahead of myself.</p>
<p>I am also blogging more regularly and trying to come up with topics that will help others (I always learn more than anybody when I write them). I am sure other things will present themselves to me and hopefully I will have the time to accept the challenge. Fortunately I have a boss who supports me!</p>
<p>The post <a href="https://sqlsolutionsgroup.com/t-sql-tuesday-61-giving-back-2/">T-SQL Tuesday #61– Giving Back!</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>&#8216;Twas the night before the upgrade&#8230;</title>
		<link>https://sqlsolutionsgroup.com/twas-the-night-before-the-upgrade/</link>
					<comments>https://sqlsolutionsgroup.com/twas-the-night-before-the-upgrade/#comments</comments>
		
		<dc:creator><![CDATA[Mike Tutor]]></dc:creator>
		<pubDate>Tue, 09 Dec 2014 13:17:40 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=1832</guid>

					<description><![CDATA[<p>‘Twas the night before the upgrade, when all through the place Not a backup was working, “there’s not enough disk space”; The software was compiled and packaged with care, In hopes that some QA was actually done there. I called the PM and he proceeded to shout, “You’re the DBA, you figure it out!” When [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/twas-the-night-before-the-upgrade/">&#8216;Twas the night before the upgrade&#8230;</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="padding-left: 30px;"><img decoding="async" class="aligncenter" src="https://www.wallpaperglow.com/wp-content/uploads/2014/11/christmas_scenery_2-1.jpg" alt="" width="800" /></p>
<p style="text-align: left;">‘Twas the night before the upgrade, when all through the place<br />
Not a backup was working, “there’s not enough disk space”;<br />
The software was compiled and packaged with care,<br />
In hopes that some QA was actually done there.</p>
<p style="text-align: left;">I called the PM and he proceeded to shout,<br />
“You’re the DBA, you figure it out!”<br />
When out of the lunchroom there arose such a clatter,<br />
I sprang from my chair to see what was the matter.</p>
<p style="text-align: left;">I ran to the door and what did I see,<br />
The developers having a potluck, they didn’t invite me.<br />
They had smartphones and tablets of every shape and size,<br />
They were typing and texting and avoiding each other’s eyes.</p>
<p style="text-align: left;">And then I saw the manager, he smiled at me wanly,<br />
I was really kind of irritated that he sat there so calmly.<br />
He was chubby and plump, kind of an ugly old toad<br />
And I laughed when I saw him, this guy was a load.</p>
<p style="text-align: left;">I told him the problem, but he didn’t seem to care<br />
I incited a response by giving him a glare.<br />
“What’s the problem?” he asked, “I heard it was clustered!”<br />
I said “I’m talking ketchup and you’re talking mustard.”</p>
<p style="text-align: left;">He scratched his bald head and looked around confused,<br />
I was amazed he could breathe, so little brain being used.<br />
I quickly turned away before I began to snigger,<br />
I still had a problem to fix and it was only growing bigger.</p>
<p style="text-align: left;">I returned to my desk, I had one more play,<br />
I called the sys admins to see what they’d say.<br />
Their response was expected, they said “It’s a bummer,”<br />
“We won’t have more disk space until sometime next summer!”</p>
<p style="text-align: left;">As much as I tried, it was plain to see,<br />
That the person to fix this was clearly going to be me.<br />
So donning my rarely seen grumpy DBA face,<br />
I put up my sign “Need help? This isn’t the place!”</p>
<p style="text-align: left;">I began searching for files I could readily delete,<br />
Hopefully a process I could repeatedly repeat.<br />
I searched and searched, I poked and prodded<br />
Looking for files that were useless and rotted.</p>
<p style="text-align: left;">Finally I found it, a folder full of crap<br />
That didn’t belong there, I could delete it in a snap.<br />
There were pictures and videos and documents aplenty,<br />
By my last count there were 14,520.</p>
<p style="text-align: left;">The files were ancient, 7 or 8 years, some older,<br />
I could with a clear conscience delete the whole folder.<br />
I opened a picture to see what was there,<br />
I saw a familiar face, but in those days he had hair.</p>
<p style="text-align: left;">Right click “delete” and the folder was demolished,<br />
I’d done a good job, one more apple polished.<br />
I looked in the trash bin, the folder I detected<br />
I emptied it quickly so it couldn’t be resurrected.</p>
<p style="text-align: left;">I dashed to the lunch room to find my bald friend<br />
To give him the sad news of his folders unfortunate end.<br />
But it was he that was laughing when my story was done<br />
There was a twinkle in his eye, he was really having fun.</p>
<p style="text-align: left;">He said, “Oh man you’re in trouble, you’re now cannon fodder,<br />
Those pix are the CEO’s, I married his daughter!”<br />
So I returned to my desk to pack up my stuff,<br />
This fateful night was over, I’d already had enough.</p>
<p style="text-align: left;">As I walked out the door, you could clearly hear me say,<br />
“To all a good night, here’s a copy of my updated résumé.”</p>
<p>The post <a href="https://sqlsolutionsgroup.com/twas-the-night-before-the-upgrade/">&#8216;Twas the night before the upgrade&#8230;</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/twas-the-night-before-the-upgrade/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>What the FK? Your Foreign Keys May Not Be Performing Like They Should</title>
		<link>https://sqlsolutionsgroup.com/fk-foreign-keys/</link>
		
		<dc:creator><![CDATA[Mike Tutor]]></dc:creator>
		<pubDate>Tue, 04 Nov 2014 17:35:45 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=1686</guid>

					<description><![CDATA[<p>Query Optimizer Tips and Tricks Part 2 &#160; This is the second installment in a continuing series of articles on things to look for and change that will help your query optimizer perform at its best.  If you missed part one, you can read it here. Okay, now that you know about trusted vs. non-trusted [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/fk-foreign-keys/">What the FK? Your Foreign Keys May Not Be Performing Like They Should</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Query Optimizer Tips and Tricks Part 2</h3>
<p>&nbsp;</p>
<p><strong>This is the second installment in a continuing series of articles on things to look for and change that will help your query optimizer perform at its best.  If you missed part one, you can read it <a title="See previous post" href="//sqlsolutionsgroup.com/query-optimizer-1/" target="_blank" rel="noopener noreferrer">here</a>.</strong></p>
<p>Okay, now that you know about trusted vs. non-trusted check constraints, let’s talk about foreign keys. What are foreign keys? They are another type of constraint, right? Just like check constraints, if they are not handled correctly the query optimizer will stop trusting them. The scenario is similar to check constraints but is, in my experience, more prevalent and usually has a greater negative impact.</p>
<h3><strong>Non-Trusted Foreign Keys</strong></h3>
<p>How many times have you been attempting a large data load, and to speed things up you disabled the foreign keys?  Data loads are much faster if it doesn’t have to keep checking each row for referential integrity (RI), right? Or, more likely is the scenario that you’ve found that you can’t load the data because something is contrary to the foreign key constraint. Just disable that pesky FK and now you can load the data no problem. Re-enable the foreign key(s) and voilà, everything works. Isn’t that convenient? Well, just as with check constraints, this scenario causes the query optimizer to no longer trust the foreign key. Just as with check constraints, if you disable a foreign key and don’t use the WITH CHECK option when you enable it, the foreign key becomes not trusted.</p>
<p>Okay, maybe <em>you’ve</em> never done this, but I guarantee you it is happening all over the SQL map. I have yet to find a company that didn’t have a fair number of non-trusted foreign keys in their production environment.</p>
<p>Let’s see what the ramifications are.</p>
<p><div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">USE</span> AdventureWorks2012;
&nbsp;
<span class="kw1">SELECT</span> name, is_not_trusted <span class="kw1">FROM</span> sys.<span class="me1">foreign_keys</span> <span class="kw1">WHERE</span> is_not_trusted <span class="sy0">=</span> <span class="nu0">1</span>;</pre></div></div></p>
<p>Presumably no rows will be returned from this query if you haven’t been messing with your foreign keys in AdventureWorks. Picking a foreign key at random, let’s disable/enable it without the WITH CHECK option:</p>
<p><div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="co1">-- Break it</span>
&nbsp;
<span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">NOCHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>FK_Person_BusinessEntity_BusinessEntityID<span class="br0">]</span>
&nbsp;
GO
&nbsp;
<span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">CHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>FK_Person_BusinessEntity_BusinessEntityID<span class="br0">]</span>
&nbsp;
GO</pre></div></div></p>
<p>Enabling the foreign key without the WITH CHECK option will enable the foreign key constraint, but the data will not be verified for integrity.</p>
<p><div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="co1">-- Check it</span>
&nbsp;
       <span class="kw1">SELECT</span> name, is_disabled, is_not_trusted <span class="kw1">FROM</span> sys.<span class="me1">foreign_keys</span>
&nbsp;
       <span class="kw1">WHERE</span> name <span class="sy0">=</span> <span class="st0">'FK_Person_BusinessEntity_BusinessEntityID'</span>;</pre></div></div></p>
<p>And it should be no surprise that the result is:</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk1.jpg"><img loading="lazy" decoding="async" class="alignleft wp-image-1687 size-full" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk1.jpg" alt="Foreign Keys 1" width="422" height="67" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk1.jpg 422w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk1-300x48.jpg 300w" sizes="(max-width: 422px) 100vw, 422px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The foreign key is no longer trusted by the optimizer. Oops! So if we query the data now, what does the query optimizer do?</p>
<p><div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="co1">-- Query it</span>
&nbsp;
<span class="kw1">SET</span> <span class="kw1">NOCOUNT</span> <span class="kw1">ON</span>;
&nbsp;
       <span class="kw1">SET</span> <span class="kw1">STATISTICS</span> XML <span class="kw1">ON</span>;
&nbsp;
       GO
&nbsp;
 
&nbsp;
<span class="kw1">SELECT</span> Person.<span class="sy0">*</span> <span class="kw1">FROM</span> Person.<span class="me1">Person</span> Person
&nbsp;
       <span class="sy0">JOIN</span> Person.<span class="me1">BusinessEntity</span> be <span class="kw1">ON</span> Person.<span class="me1">BusinessEntityID</span> <span class="sy0">=</span> be.<span class="me1">BusinessEntityID</span>;
&nbsp;
 
&nbsp;
       <span class="kw1">SET</span> <span class="kw1">STATISTICS</span> XML <span class="kw1">OFF</span>;
&nbsp;
       <span class="kw1">SET</span> <span class="kw1">NOCOUNT</span> <span class="kw1">OFF</span>;
&nbsp;
       GO</pre></div></div></p>
<p>The stats and execution plan we generated:</p>
<pre style="padding-left: 30px;">Table 'Person'. Scan count 1, logical reads 3820, physical reads 2, read-ahead reads 3826

Table 'BusinessEntity'. Scan count 1, logical reads 98, physical reads 1, read-ahead reads 96

        SQL Server Execution Times:

        CPU time = 218 ms,  elapsed time = 2785 ms.</pre>
<p>&nbsp;</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk2.jpg"><img loading="lazy" decoding="async" class="alignleft wp-image-1688 size-full" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk2.jpg" alt="Foreign Keys 2" width="459" height="180" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk2.jpg 459w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk2-300x118.jpg 300w" sizes="(max-width: 459px) 100vw, 459px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Note that there is a scan of both the Person and BusinessEntity tables.</p>
<p>Now, let’s make the foreign key <strong>trusted</strong> by enabling the foreign key again using the WITH CHECK option:</p>
<p><div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"> <span class="co1">-- Fix it</span>
&nbsp;
<span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">WITH</span> <span class="kw1">CHECK</span> <span class="kw1">CHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>FK_Person_BusinessEntity_BusinessEntityID<span class="br0">]</span>
&nbsp;
GO</pre></div></div></p>
<p>The WITH CHECK option will cause SQL Server to check all the data to verify that it does not conflict with the foreign key constraint.</p>
<p><strong>NOTE</strong>: If the tables involved are large this may take some time and you may not want to do it during normal operational hours</p>
<p><div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="co1">-- Check it</span>
&nbsp;
       <span class="kw1">SELECT</span> name, is_disabled, is_not_trusted <span class="kw1">FROM</span> sys.<span class="me1">foreign_keys</span>
&nbsp;
       <span class="kw1">WHERE</span> name <span class="sy0">=</span> <span class="st0">'FK_Person_BusinessEntity_BusinessEntityID'</span>;</pre></div></div></p>
<p>Now the result is:</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk3.jpg"><img loading="lazy" decoding="async" class="alignleft wp-image-1689 size-full" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk3.jpg" alt="Foreign Keys 3" width="417" height="72" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk3.jpg 417w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk3-300x52.jpg 300w" sizes="(max-width: 417px) 100vw, 417px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The foreign key is now trusted by the optimizer. So if we query the data now, what does the query optimizer do?</p>
<p><div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"> <span class="co1">-- Query it</span>
&nbsp;
<span class="kw1">SET</span> <span class="kw1">NOCOUNT</span> <span class="kw1">ON</span>;
&nbsp;
       <span class="kw1">SET</span> <span class="kw1">STATISTICS</span> XML <span class="kw1">ON</span>;
&nbsp;
       GO
&nbsp;
 
&nbsp;
<span class="kw1">SELECT</span> Person.<span class="sy0">*</span> <span class="kw1">FROM</span> Person.<span class="me1">Person</span> Person
&nbsp;
       <span class="sy0">JOIN</span> Person.<span class="me1">BusinessEntity</span> be <span class="kw1">ON</span> Person.<span class="me1">BusinessEntityID</span> <span class="sy0">=</span> be.<span class="me1">BusinessEntityID</span>;
&nbsp;
 
&nbsp;
       <span class="kw1">SET</span> <span class="kw1">STATISTICS</span> XML <span class="kw1">OFF</span>;
&nbsp;
       <span class="kw1">SET</span> <span class="kw1">NOCOUNT</span> <span class="kw1">OFF</span>;
&nbsp;
       GO</pre></div></div></p>
<p>&nbsp;</p>
<p>The stats and execution plan we generated:</p>
<p style="padding-left: 30px;">Table &#8216;Person&#8217;. Scan count 1, logical reads 3820, physical reads 2, read-ahead reads 3826</p>
<p style="padding-left: 30px;">SQL Server Execution Times:</p>
<p style="padding-left: 30px;">   CPU time = 156 ms,  elapsed time = 2310 ms.</p>
<p>&nbsp;</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk4.jpg"><img loading="lazy" decoding="async" class="alignleft wp-image-1690 size-full" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk4.jpg" alt="Foreign Keys 4" width="321" height="115" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk4.jpg 321w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/11/Fk4-300x107.jpg 300w" sizes="(max-width: 321px) 100vw, 321px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Wow, look at that! The Person table has been completely dropped from the query and there is no merge either. The query optimizer trusted the foreign key and therefore did not have go check the data in the Person table to verify that the data met the criteria.  The difference is visible even in these small tables, it could be significant if these were large tables.</p>
<p>And here is the T-SQL script that will find all your non-trusted foreign keys:</p>
<p><div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">EXEC</span> sp_MSforEachDB N<span class="st0">'
&nbsp;
USE [?];
&nbsp;
SELECT fk.name, fk.is_not_trusted, '</span><span class="st0">'Database Table'</span><span class="st0">' = '</span><span class="st0">'?'</span><span class="st0">' + '</span><span class="st0">'.'</span><span class="st0">' + sch.name + '</span><span class="st0">'.'</span><span class="st0">' + obj.name
&nbsp;
FROM sys.foreign_keys fk
&nbsp;
JOIN sys.all_objects obj ON fk.parent_object_id = obj.object_id
&nbsp;
JOIN sys.schemas sch ON fk.schema_id = sch.schema_id
&nbsp;
WHERE fk.is_not_trusted = 1'</span></pre></div></div></p>
<p>&nbsp;</p>
<h3><strong>Conclusion</strong></h3>
<p>The case for checking your foreign keys for the is_not_trusted flag has been made, and now that you know what the ramifications are, get out there and do it!  You may not be the one causing the problem, but if you’re not the only person working on an instance, somebody WILL disable foreign keys to speed up data loads, or to get around bad data.</p>
<p>&nbsp;</p>
<p>The post <a href="https://sqlsolutionsgroup.com/fk-foreign-keys/">What the FK? Your Foreign Keys May Not Be Performing Like They Should</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Query Optimizer Tips and Tricks Part 1: Trusted vs. Non-Trusted Constraints</title>
		<link>https://sqlsolutionsgroup.com/query-optimizer-1/</link>
		
		<dc:creator><![CDATA[Mike Tutor]]></dc:creator>
		<pubDate>Tue, 23 Sep 2014 21:12:59 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=1523</guid>

					<description><![CDATA[<p>Query Optimizer Part 1 It may come as a surprise to you to find out that at its core, the SQL Server Query Optimizer is like a jealous lover. How so? The optimizer doesn’t trust the constraints on your data until you prove to it that your data is trustworthy! Why do you care? Because if [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/query-optimizer-1/">Query Optimizer Tips and Tricks Part 1: Trusted vs. Non-Trusted Constraints</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><strong>Query Optimizer Part 1</strong></h3>
<p>It may come as a surprise to you to find out that at its core, the SQL Server Query Optimizer is like a jealous lover. How so? The optimizer doesn’t trust the constraints on your data until you prove to it that your data is trustworthy! Why do you care? Because if the optimizer doesn’t trust your constraints then it feels the need to check the data to make sure it is right. This article discusses how the constraints get on the query optimizer’s bad side, how to find the wayward constraints, what effect having non-trusted constraints has on a query, and how to bring them back into the optimizer’s good graces.</p>
<h4><strong>Non-Trusted Constraints</strong></h4>
<p>How do your constraints become non-trusted constraints? It’s simple. If you disable a constraint, and then do not specify the WITH CHECK option when you enable it, SQL Server does not check the data to make sure it meets the criteria of the constraint. Some people do this intentionally to enter data into a table that is contrary to the constraint (a bad practice), but more often, they simply did not know to use the WITH CHECK option when enabling. When this happens (intentionally or not), the SQL optimizer no longer trusts your data. Remember, she is a jealous lover (I’m a guy, so I’m going with &#8220;she&#8221; here). When your data is out of her watchful eye for even just a minute she won’t trust the data again until she can see for herself that the data deserves her trust. Your constraint is branded as untrustworthy… or slightly less dramatically, the constraint is denoted as a non-trusted constraint by the is_not_trusted column in sys.check_contraints = ‘1’.</p>
<p>Let’s look at an example by looking at good ‘ol AdventureWorks to see if you have any non-trusted check constraints.</p>
<p><div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">USE</span> AdventureWorks2012;
GO
<span class="kw1">SELECT</span> name, is_not_trusted <span class="kw1">FROM</span> sys.<span class="me1">check_constraints</span> <span class="kw1">WHERE</span> is_not_trusted <span class="sy0">=</span> <span class="nu0">1</span>;</pre></div></div></p>
<p>&nbsp;</p>
<p>Presumably, this should return no rows if you haven’t been messing around with AdventureWorks constraints (She will know!). Now let’s disable and re-enable a constraint without the WITH CHECK option.</p>
<p><div id="wpshdo_11" class="wp-synhighlighter-outer"><div id="wpshdt_11" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_11"></a><a id="wpshat_11" class="wp-synhighlighter-title" href="#codesyntax_11"  onClick="javascript:wpsh_toggleBlock(11)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_11" onClick="javascript:wpsh_code(11)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_print(11)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_11" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span>  <span class="kw1">NOCHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>CK_Person_EmailPromotion<span class="br0">]</span>
GO
<span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">CHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>CK_Person_EmailPromotion<span class="br0">]</span>
GO
<span class="kw1">SELECT</span> name, is_not_trusted <span class="kw1">FROM</span> sys.<span class="me1">check_constraints</span>
<span class="kw1">WHERE</span> name <span class="sy0">=</span> <span class="st0">'CK_Person_EmailPromotion'</span>;</pre></div></div></p>
<p>&nbsp;</p>
<p>The select now returns:</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer1.jpg"><img loading="lazy" decoding="async" class="alignleft wp-image-1529 size-full" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer1.jpg" alt="Query_Optimizer_1" width="435" height="128" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer1.jpg 435w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer1-300x88.jpg 300w" sizes="(max-width: 435px) 100vw, 435px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Well, there you go. Now the optimizer is all up in your query plans (we’ll see those later), checking your data because she no longer trusts that it is consistent. How do we calm her frazzled sensibilities? You guessed it (I hope). We allow SQL Server to check and verify that the data is correct by re-enabling the constraint utilizing WITH CHECK:</p>
<p><div id="wpshdo_12" class="wp-synhighlighter-outer"><div id="wpshdt_12" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_12"></a><a id="wpshat_12" class="wp-synhighlighter-title" href="#codesyntax_12"  onClick="javascript:wpsh_toggleBlock(12)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_12" onClick="javascript:wpsh_code(12)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_print(12)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_12" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">WITH</span> <span class="kw1">CHECK</span> <span class="kw1">CHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>CK_Person_EmailPromotion<span class="br0">]</span>
GO</pre></div></div></p>
<p>&nbsp;</p>
<p>The select now returns:</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer2.jpg"><img loading="lazy" decoding="async" class="alignleft size-full wp-image-1528" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer2.jpg" alt="Query_Optimizer_2" width="435" height="126" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer2.jpg 435w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer2-300x87.jpg 300w" sizes="(max-width: 435px) 100vw, 435px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>Note:</strong> The WITH CHECK option causes SQL Server to read all the data in the table for the affected column. If the table in question is very large it may take a while, and you may not want to do it on a production server during normal operational hours.</p>
<p>So why doesn’t SQL Server trust the constraint if the data is not checked when you enable it? Because while the constraint is disabled you could enter data that is contrary to the constraint. In the above example, the constraint ‘CK_Person_EmailPromotion’ defines that the column EmailPromotion on the Person table must be &gt;= 0 or &lt;= 2.</p>
<p><div id="wpshdo_13" class="wp-synhighlighter-outer"><div id="wpshdt_13" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_13"></a><a id="wpshat_13" class="wp-synhighlighter-title" href="#codesyntax_13"  onClick="javascript:wpsh_toggleBlock(13)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_13" onClick="javascript:wpsh_code(13)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_print(13)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_13" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span>  <span class="kw1">WITH</span> <span class="kw1">CHECK</span> <span class="kw1">ADD</span>  <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>CK_Person_EmailPromotion<span class="br0">]</span> <span class="kw1">CHECK</span>  <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="br0">[</span>EmailPromotion<span class="br0">]</span><span class="sy0">&gt;=</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span> <span class="sy0">AND</span> <span class="br0">[</span>EmailPromotion<span class="br0">]</span><span class="sy0">&lt;=</span><span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
GO</pre></div></div></p>
<p>&nbsp;</p>
<p>So, if you did this:</p>
<p><div id="wpshdo_14" class="wp-synhighlighter-outer"><div id="wpshdt_14" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_14"></a><a id="wpshat_14" class="wp-synhighlighter-title" href="#codesyntax_14"  onClick="javascript:wpsh_toggleBlock(14)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_14" onClick="javascript:wpsh_code(14)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_print(14)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_14" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span>  <span class="kw1">NOCHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>CK_Person_EmailPromotion<span class="br0">]</span>
GO
<span class="kw1">UPDATE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">SET</span> EmailPromotion <span class="sy0">=</span> 3 <span class="kw1">WHERE</span> BusinessEntityID <span class="sy0">=</span> <span class="nu0">1</span>;
<span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">CHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>CK_Person_EmailPromotion<span class="br0">]</span>
GO</pre></div></div></p>
<p>&nbsp;</p>
<p>You would have data in the table that does not comply with the constraint (EmailPromotion = 3). The optimizer is right not to trust your data. If you try to enable the constraint using WITH CHECK now,  it fails.</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer3.jpg"><img loading="lazy" decoding="async" class="alignleft size-full wp-image-1527" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer3.jpg" alt="Query_Optimizer_3" width="628" height="138" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer3.jpg 628w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer3-300x66.jpg 300w" sizes="(max-width: 628px) 100vw, 628px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Now you have to fix the data and then you can enable the constraint using WITH CHECK.</p>
<p><div id="wpshdo_15" class="wp-synhighlighter-outer"><div id="wpshdt_15" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_15"></a><a id="wpshat_15" class="wp-synhighlighter-title" href="#codesyntax_15"  onClick="javascript:wpsh_toggleBlock(15)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_15" onClick="javascript:wpsh_code(15)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_print(15)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_15" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">UPDATE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">SET</span> EmailPromotion <span class="sy0">=</span> 0 <span class="kw1">WHERE</span> BusinessEntityID <span class="sy0">=</span> <span class="nu0">1</span>;
&nbsp;
<span class="kw1">ALTER</span> <span class="kw1">TABLE</span> <span class="br0">[</span>Person<span class="br0">]</span>.<span class="br0">[</span>Person<span class="br0">]</span> <span class="kw1">WITH</span> <span class="kw1">CHECK</span> <span class="kw1">CHECK</span> <span class="kw1">CONSTRAINT</span> <span class="br0">[</span>CK_Person_EmailPromotion<span class="br0">]</span>
&nbsp;
GO</pre></div></div></p>
<p>&nbsp;</p>
<p>As I mentioned earlier, this has consequences for the optimizer and your query plans. Let’s check it out. If we run the following select statement while the CK_Person_EmailPromotion constraint is trusted (is_not_trusted = 0):</p>
<p><div id="wpshdo_16" class="wp-synhighlighter-outer"><div id="wpshdt_16" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_16"></a><a id="wpshat_16" class="wp-synhighlighter-title" href="#codesyntax_16"  onClick="javascript:wpsh_toggleBlock(16)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_16" onClick="javascript:wpsh_code(16)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_16" onClick="javascript:wpsh_print(16)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_16" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">SET</span> <span class="kw1">STATISTICS</span> IO,<span class="kw1">TIME</span> <span class="kw1">ON</span>;
<span class="kw1">SET</span> <span class="kw1">STATISTICS</span> XML <span class="kw1">ON</span>;
GO
<span class="kw1">SELECT</span> FirstName, LastName <span class="kw1">FROM</span> Person.<span class="me1">Person</span> <span class="kw1">WHERE</span> EmailPromotion <span class="sy0">=</span> <span class="nu0">3</span></pre></div></div></p>
<p>&nbsp;</p>
<p>We get the following statistics:</p>
<p style="padding-left: 30px;">SQL Server parse and compile time:</p>
<p style="padding-left: 30px;">CPU time = 0 ms, elapsed time = 0 ms.</p>
<p style="padding-left: 30px;">SQL Server parse and compile time:</p>
<p style="padding-left: 30px;">CPU time = 0 ms, elapsed time = 0 ms.</p>
<p style="padding-left: 30px;">SQL Server Execution Times:</p>
<p style="padding-left: 30px;">CPU time = 0 ms,  elapsed time = 0 ms.</p>
<p>And here is the Query Plan.</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer4.jpg"><img loading="lazy" decoding="async" class="alignleft size-full wp-image-1526" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer4.jpg" alt="Query_Optimizer_4" width="628" height="123" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer4.jpg 628w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer4-300x59.jpg 300w" sizes="(max-width: 628px) 100vw, 628px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>If we now run the same query while the CK_Person_EmailPromotion constraint is NOT trusted (is_not_trusted = 1), our statistics look like this:</p>
<p style="padding-left: 30px;">SQL Server parse and compile time:</p>
<p style="padding-left: 30px;">CPU time = 0 ms, elapsed time = 16 ms.</p>
<p style="padding-left: 30px;">SQL Server parse and compile time:</p>
<p style="padding-left: 30px;">CPU time = 0 ms, elapsed time = 0 ms.</p>
<p style="padding-left: 30px;">Table &#8216;Person&#8217;. Scan count 1, logical reads 3820, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.</p>
<p style="padding-left: 30px;">SQL Server Execution Times:</p>
<p style="padding-left: 30px;">CPU time = 16 ms,  elapsed time = 11 ms.</p>
<p>&nbsp;</p>
<p>And our Query Plan now has an Index Scan in it:</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer5.jpg"><img loading="lazy" decoding="async" class="alignleft size-full wp-image-1525" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer5.jpg" alt="Query_Optimizer_5" width="424" height="156" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer5.jpg 424w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/09/QueryOptimizer5-300x110.jpg 300w" sizes="(max-width: 424px) 100vw, 424px" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Notice that the 2<sup>nd</sup> query with the non-trusted constraint has a clustered index scan with 3820 logical reads. The 1<sup>st</sup> query with the trusted constraint has zero logical reads and no index scan. Why? Well, if you remember the constraint stipulated that the value of the EmailPromotion column had to be <strong>&gt;= 0 and &lt;= 2</strong>. The query is looking for all rows with an EmailPromotion = <strong>3</strong>. When the optimizer trusts your constraint it knows that none of the rows will meet that criteria, so it doesn’t even bother to look. However, if the optimizer doesn’t trust your constraint, it has to scan every row to see if any have the value of 3, a value that clearly could be there (since we added one) if the constraint is not trusted. This is a simple example on a small table but you can see where this could be costly on a larger table.</p>
<p>Here is a nice T-SQL script that will find all your non-trusted constraints:</p>
<p><div id="wpshdo_17" class="wp-synhighlighter-outer"><div id="wpshdt_17" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_17"></a><a id="wpshat_17" class="wp-synhighlighter-title" href="#codesyntax_17"  onClick="javascript:wpsh_toggleBlock(17)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_17" onClick="javascript:wpsh_code(17)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_17" onClick="javascript:wpsh_print(17)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_17" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">EXEC</span> sp_MSforeachdb N<span class="st0">'
USE [?];
SELECT chk.name, chk.is_not_trusted, [Database Table] = '</span><span class="st0">'?'</span><span class="st0">' + '</span><span class="st0">'.'</span><span class="st0">' + sch.name + '</span><span class="st0">'.'</span><span class="st0">' + obj.name
FROM sys.check_constraints chk
JOIN sys.all_objects obj ON chk.parent_object_id = obj.object_id
JOIN sys.schemas sch ON chk.schema_id = sch.schema_id
WHERE chk.is_not_trusted = 1'</span></pre></div></div></p>
<p>&nbsp;</p>
<h3><strong>Conclusion</strong></h3>
<p>If you’re not checking your constraints for the is_not_trusted flag , you should be. This is especially true if you have developers that have access to your production databases. Developers WILL disable constraints to speed up data loads, or to get around bad data. I like to think that we as DBAs would know better, but I am sure we’ve all done it too (not me!). Now that you know what the ramifications are, get out there and find those wayward constraints and bring them back into the optimizer’s good graces. She won’t be jealous if you are always on the up and up!</p>
<p>The post <a href="https://sqlsolutionsgroup.com/query-optimizer-1/">Query Optimizer Tips and Tricks Part 1: Trusted vs. Non-Trusted Constraints</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Moving Databases to New Drives: A Real-world Case Study Involving 120 Databases</title>
		<link>https://sqlsolutionsgroup.com/moving-databases/</link>
		
		<dc:creator><![CDATA[Mike Tutor]]></dc:creator>
		<pubDate>Tue, 29 Jul 2014 22:29:58 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=1241</guid>

					<description><![CDATA[<p>Moving databases is a common enough task for the DBA, and there are multiple ways to move physical database files from one drive to another. Depending on your preference, you can either use the DETACH/ATTACH method: &#160; Or you can use the ALTER DATABASE method: Whichever method you prefer, these work great when you are [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/moving-databases/">Moving Databases to New Drives: A Real-world Case Study Involving 120 Databases</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Moving databases is a common enough task for the DBA, and there are multiple ways to move physical database files from one drive to another. Depending on your preference, you can either use the DETACH/ATTACH method:</p>
<p><div id="wpshdo_18" class="wp-synhighlighter-outer"><div id="wpshdt_18" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_18"></a><a id="wpshat_18" class="wp-synhighlighter-title" href="#codesyntax_18"  onClick="javascript:wpsh_toggleBlock(18)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_18" onClick="javascript:wpsh_code(18)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_18" onClick="javascript:wpsh_print(18)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_18" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">USE</span> AdventureWorks2012;
GO
<span class="kw3">SP_HELPFILE</span>  <span class="co1">-- to get the logical file names and current physical file locations</span>
<span class="kw1">USE</span> master;
GO
<span class="kw3">SP_DETACH_DB</span> <span class="st0">'AdventureWorks2012'</span>;
GO
<span class="co1">-- Move the physical data/log files to the new location</span>
<span class="kw3">SP_ATTACH_DB</span> <span class="st0">'AdventureWorks2012'</span>, <span class="st0">'D:<span class="es0">\M</span>SSQL<span class="es0">\D</span>ATA<span class="es0">\A</span>dventureWorks2012_Data.mdf'</span>,<span class="st0">'F:<span class="es0">\M</span>SSQL<span class="es0">\L</span>OG<span class="es0">\A</span>dventureWorks2012_log.ldf'</span>;
GO</pre></div></div></p>
<p>&nbsp;</p>
<p>Or you can use the ALTER DATABASE method:</p>
<p><div id="wpshdo_19" class="wp-synhighlighter-outer"><div id="wpshdt_19" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_19"></a><a id="wpshat_19" class="wp-synhighlighter-title" href="#codesyntax_19"  onClick="javascript:wpsh_toggleBlock(19)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_19" onClick="javascript:wpsh_code(19)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_19" onClick="javascript:wpsh_print(19)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_19" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>AdventureWorks2012<span class="br0">]</span> <span class="kw1">MODIFY</span> <span class="kw1">FILE</span> <span class="br0">&#40;</span>NAME <span class="sy0">=</span> <span class="br0">[</span>AdventureWorks2012_Data<span class="br0">]</span>, FILENAME <span class="sy0">=</span> <span class="st0">'D:<span class="es0">\M</span>SSQL<span class="es0">\D</span>ATA<span class="es0">\A</span>dventureWorks2012_Data.mdf'</span><span class="br0">&#41;</span>;
<span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>AdventureWorks2012<span class="br0">]</span> <span class="kw1">MODIFY</span> <span class="kw1">FILE</span> <span class="br0">&#40;</span>NAME <span class="sy0">=</span> <span class="br0">[</span>AdventureWorks2012_Log<span class="br0">]</span>, FILENAME <span class="sy0">=</span> <span class="st0">'F:<span class="es0">\M</span>SSQL<span class="es0">\L</span>OG<span class="es0">\A</span>dventureWorks2012_log.ldf'</span><span class="br0">&#41;</span>
<span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>AdventureWorks2012<span class="br0">]</span> <span class="kw1">SET</span> OFFL<span class="sy0">IN</span>E
<span class="co1">-- Move the physical data/log files to the new location</span>
<span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>AdventureWorks2012<span class="br0">]</span> <span class="kw1">SET</span> ONL<span class="sy0">IN</span>E</pre></div></div></p>
<p>Whichever method you prefer, these work great when you are moving databases, especially if just a handful.</p>
<p>But, what if you are moving 120 databases from numerous disk drives which may or may not be well documented? This was the situation we were recently presented with at a customer site where they had acquired new SAN storage that they wanted to utilize. The 120 databases were spread across 7 different disk drives in an undocumented disarray, and a few had already been created on or moved to the new drives. So how to proceed?</p>
<p>First, we built a table that had all the information in it that we needed to do some analysis, and then to generate a move script. What did we need to know?</p>
<ul>
<li>What databases are to be moved?</li>
<li>Where they are currently located?</li>
<li>Where they are to be moved to?</li>
<li>How much disk space is required?</li>
</ul>
<p>So the table needed to have the following information in it for each database:</p>
<ul>
<li>Database id</li>
<li>File id for each database file</li>
<li>Filename (logical file names)</li>
<li>Physical Filename</li>
<li>Original Location (fully qualified physical filename)</li>
<li>Original directory</li>
<li>New location</li>
<li>New directory</li>
<li>File type (‘ROWS’ = data, ‘LOG’ = logs)</li>
<li>Size in MB (for each file)</li>
<li>Database status (read only, offline etc.)</li>
</ul>
<p>In this real world scenario, the disk locations were predefined by the customer.  If you are given a choice, you would like to put your data, log and tempdb files on disparate disks. Fortunately, the locations provided for this migration met that criteria.</p>
<p>We defined the locations where we wanted to move our database files as follows:</p>
<p><div id="wpshdo_20" class="wp-synhighlighter-outer"><div id="wpshdt_20" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_20"></a><a id="wpshat_20" class="wp-synhighlighter-title" href="#codesyntax_20"  onClick="javascript:wpsh_toggleBlock(20)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_20" onClick="javascript:wpsh_code(20)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_20" onClick="javascript:wpsh_print(20)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_20" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="co1">-- Define the drives you wish to move the data files to. Do not put '\' on the end.</span>
<span class="kw1">DECLARE</span>	 @systemDBData		<span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="st0">'G:<span class="es0">\M</span>SSQL<span class="es0">\S</span>YSTEM_DATA'</span>
	,@systemDBLog		<span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="st0">'F:<span class="es0">\M</span>SSQL<span class="es0">\S</span>YSTEM_LOG'</span>
	,@tempDBData		<span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="st0">'E:<span class="es0">\M</span>SSQL<span class="es0">\T</span>EMPDB_DATA'</span>
	,@tempDBLog		<span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="st0">'E:<span class="es0">\M</span>SSQL<span class="es0">\T</span>EMPDB_LOG'</span> 
	,@userDBData		<span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="st0">'G:<span class="es0">\M</span>SSQL<span class="es0">\U</span>SER_DATA'</span>
	,@userDBLog		<span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="st0">'F:<span class="es0">\M</span>SSQL<span class="es0">\U</span>SER_LOG'</span></pre></div></div></p>
<p>We also defined all the disks that we wanted to search for existing database file by creating an array of disks as follows:</p>
<p><div id="wpshdo_21" class="wp-synhighlighter-outer"><div id="wpshdt_21" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_21"></a><a id="wpshat_21" class="wp-synhighlighter-title" href="#codesyntax_21"  onClick="javascript:wpsh_toggleBlock(21)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_21" onClick="javascript:wpsh_code(21)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_21" onClick="javascript:wpsh_print(21)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_21" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">DECLARE</span>	 @fromDrive		<span class="kw1">TABLE</span><span class="br0">&#40;</span>Drive <span class="kw1">CHAR</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
<span class="co1">--Insert the Drive(s) You want to check for database files</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> @fromDrive <span class="br0">&#40;</span>Drive<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="st0">'C'</span><span class="br0">&#41;</span>,<span class="br0">&#40;</span><span class="st0">'D'</span><span class="br0">&#41;</span>,<span class="br0">&#40;</span><span class="st0">'E'</span><span class="br0">&#41;</span>,<span class="br0">&#40;</span><span class="st0">'F'</span><span class="br0">&#41;</span>,<span class="br0">&#40;</span><span class="st0">'G'</span><span class="br0">&#41;</span>,<span class="br0">&#40;</span><span class="st0">'I'</span><span class="br0">&#41;</span>,<span class="br0">&#40;</span><span class="st0">'M'</span><span class="br0">&#41;</span></pre></div></div></p>
<p>So now we were ready to gather all the data into our table. Not only does this table provide data for pre-move analysis and to create our move script, but it also provides a log of sorts.</p>
<p><div id="wpshdo_22" class="wp-synhighlighter-outer"><div id="wpshdt_22" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_22"></a><a id="wpshat_22" class="wp-synhighlighter-title" href="#codesyntax_22"  onClick="javascript:wpsh_toggleBlock(22)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_22" onClick="javascript:wpsh_code(22)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_22" onClick="javascript:wpsh_print(22)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_22" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">IF</span> <span class="kw2">OBJECT_ID</span><span class="br0">&#40;</span> <span class="st0">'DBA.dbo.MOVE_Servername_Log'</span> <span class="br0">&#41;</span> <span class="kw1">IS</span> <span class="sy0">NOT</span> <span class="sy0">NULL</span> <span class="kw1">DROP</span> <span class="kw1">TABLE</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
<span class="kw1">SELECT</span>
masterFiles.<span class="me1">database_id</span>,
masterFiles.<span class="kw2">FILE_ID</span>,
db.<span class="me1">name</span> <span class="kw1">AS</span> DatabaseName,
masterFiles.<span class="me1">name</span> <span class="kw1">AS</span> FileName,
<span class="kw1">RIGHT</span><span class="br0">&#40;</span>masterFiles.<span class="me1">physical_name</span>,<span class="kw2">CHARINDEX</span><span class="br0">&#40;</span><span class="st0">'<span class="es0">\'</span>,REVERSE(masterFiles.physical_name))-1) AS PhysFileName,
masterFiles.physical_name AS OriginalLocation,
LEFT(masterFiles.physical_name,LEN(masterFiles.physical_name) –
CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))) AS OriginalDir,
CASE
WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' AND db.name IN('</span>master<span class="st0">', '</span>model<span class="st0">', '</span>msdb<span class="st0">', '</span>distribution<span class="st0">')
THEN @systemDBData + '</span>\<span class="st0">' +
RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
WHEN masterFiles.type_desc = '</span><span class="kw2">LOG</span><span class="st0">' AND db.name IN('</span>master<span class="st0">', '</span>model<span class="st0">', '</span>msdb<span class="st0">', '</span>distribution<span class="st0">')
THEN @systemDBLog + '</span>\<span class="st0">' +
RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' AND db.name = '</span>tempdb<span class="st0">'
THEN @tempDBData + '</span>\<span class="st0">' +
RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
WHEN masterFiles.type_desc = '</span><span class="kw2">LOG</span><span class="st0">' AND db.name = '</span>tempdb<span class="st0">'
THEN @tempDBLog + '</span>\<span class="st0">' +
RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">'
THEN @userDBData + '</span>\<span class="st0">' +
RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
ELSE @userDBLog  + '</span>\<span class="st0">' +
RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
END AS NewLocation,
CASE
WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' AND db.name IN('</span>master<span class="st0">', '</span>model<span class="st0">', '</span>msdb<span class="st0">', '</span>distribution<span class="st0">')
THEN @systemDBData
WHEN masterFiles.type_desc = '</span><span class="kw2">LOG</span><span class="st0">' AND db.name IN('</span>master<span class="st0">', '</span>model<span class="st0">', '</span>msdb<span class="st0">', '</span>distribution<span class="st0">')
THEN @systemDBLog
WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' AND db.name = '</span>tempdb<span class="st0">' THEN @tempDBData
WHEN masterFiles.type_desc = '</span><span class="kw2">LOG</span><span class="st0">' AND db.name = '</span>tempdb<span class="st0">' THEN @tempDBLog
WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' THEN @userDBData
ELSE @userDBLog
END AS NewLocationDir,
masterFiles.type_desc AS FileType,
masterFiles.size * 8 / 1024 AS Size_MB,
fdrv.Drive AS FromDrive,
'</span> <span class="st0">' AS ToDrive,
CASE
WHEN DATABASEPROPERTY(db.name,'</span>isReadOnly<span class="st0">') = 1 THEN '</span>isReadOnly<span class="st0">'
WHEN DATABASEPROPERTY(db.name,'</span>isOffline<span class="st0">') = 1 THEN '</span>isOffline<span class="st0">'
WHEN DATABASEPROPERTY(db.name,'</span>isSuspect<span class="st0">') = 1 THEN '</span>isSuspect<span class="st0">'
WHEN DATABASEPROPERTY(db.name,'</span>isInRecovery<span class="st0">') = 1 THEN '</span>isInRecovery<span class="st0">'
WHEN DATABASEPROPERTY(db.name,'</span>isInLoad<span class="st0">') = 1 THEN '</span>isInLoad<span class="st0">'
WHEN DATABASEPROPERTY(db.name,'</span>isNotRecovered<span class="st0">') = 1 THEN '</span>isNotRecovered<span class="st0">'
ELSE '</span>isAvailable<span class="st0">'
END AS DatabaseAvailable
INTO DBA.dbo.MOVE_Servername_Log
FROM sys.master_files masterFiles
JOIN sys.sysdatabases db ON masterFiles.database_id = db.dbid
JOIN @fromDrive fdrv ON LEFT(masterFiles.physical_name, 1) = fdrv.Drive
ORDER BY masterFiles.name
UPDATE DBA.dbo.MOVE_Servername_Log SET ToDrive = LEFT(NewLocation,1)
IF OBJECT_ID( '</span>DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span><span class="st0">' ) IS NOT NULL DROP TABLE DBA.dbo.MOVE_Servername_Log
SELECT
    masterFiles.database_id,
    masterFiles.file_id, 
    db.name AS DatabaseName,
    masterFiles.name AS FileName, 
    RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1) AS PhysFileName,
    masterFiles.physical_name AS OriginalLocation,
    LEFT(masterFiles.physical_name,LEN(masterFiles.physical_name) – 
        CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))) AS OriginalDir,
    CASE 
        WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' AND db.name IN ('</span>master<span class="st0">', '</span>model<span class="st0">', '</span>msdb<span class="st0">', '</span>distribution<span class="st0">')
            THEN @systemDBData + '</span>\<span class="st0">' + 
            RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
        WHEN masterFiles.type_desc = '</span><span class="kw2">LOG</span><span class="st0">' AND db.name IN ('</span>master<span class="st0">', '</span>model<span class="st0">', '</span>msdb<span class="st0">', '</span>distribution<span class="st0">')
            THEN @systemDBLog + '</span>\<span class="st0">' + 
             RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
        WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' AND db.name = '</span>tempdb<span class="st0">'
            THEN @tempDBData + '</span>\<span class="st0">' + 
            RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
        WHEN masterFiles.type_desc = '</span><span class="kw2">LOG</span><span class="st0">' AND db.name = '</span>tempdb<span class="st0">'
            THEN @tempDBLog + '</span>\<span class="st0">' + 
            RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1)
        WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">'
            THEN @userDBData + '</span>\<span class="st0">' + 
            RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1) 
        ELSE @userDBLog  + '</span>\<span class="st0">' + 
            RIGHT(masterFiles.physical_name,CHARINDEX('</span>\<span class="st0">',REVERSE(masterFiles.physical_name))-1) 
    END AS NewLocation,
    CASE 
        WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' AND db.name IN ('</span>master<span class="st0">', '</span>model<span class="st0">', '</span>msdb<span class="st0">', '</span>distribution<span class="st0">') 
            THEN @systemDBData
        WHEN masterFiles.type_desc = '</span><span class="kw2">LOG</span><span class="st0">' AND db.name IN ('</span>master<span class="st0">', '</span>model<span class="st0">', '</span>msdb<span class="st0">', '</span>distribution<span class="st0">')
            THEN @systemDBLog
        WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' AND db.name = '</span>tempdb<span class="st0">' THEN @tempDBData
        WHEN masterFiles.type_desc = '</span><span class="kw2">LOG</span><span class="st0">' AND db.name = '</span>tempdb<span class="st0">' THEN @tempDBLog
        WHEN masterFiles.type_desc = '</span><span class="kw1">ROWS</span><span class="st0">' THEN @userDBData
        ELSE @userDBLog
    END AS NewLocationDir,
    masterFiles.type_desc AS FileType, 
    masterFiles.size * 8 / 1024 AS Size_MB,
    fdrv.Drive AS FromDrive, 
   '</span> <span class="st0">' AS ToDrive,
    CASE
        WHEN DATABASEPROPERTY(db.name,'</span>isReadOnly<span class="st0">') = 1 THEN '</span>isReadOnly<span class="st0">'
        WHEN DATABASEPROPERTY(db.name,'</span>isOffline<span class="st0">') = 1 THEN '</span>isOffline<span class="st0">'
        WHEN DATABASEPROPERTY(db.name,'</span>isSuspect<span class="st0">') = 1 THEN '</span>isSuspect<span class="st0">'
        WHEN DATABASEPROPERTY(db.name,'</span>isInRecovery<span class="st0">') = 1 THEN '</span>isInRecovery<span class="st0">'
        WHEN DATABASEPROPERTY(db.name,'</span>isInLoad<span class="st0">') = 1 THEN '</span>isInLoad<span class="st0">'
        WHEN DATABASEPROPERTY(db.name,'</span>isNotRecovered<span class="st0">') = 1 THEN '</span>isNotRecovered<span class="st0">'
        ELSE '</span>isAvailable<span class="st0">'
    END AS DatabaseAvailable
INTO DBA.dbo.MOVE_Servername_Log
FROM sys.master_files masterFiles
JOIN sys.sysdatabases db ON masterFiles.database_id = db.dbid
JOIN @fromDrive fdrv ON LEFT(masterFiles.physical_name, 1) = fdrv.Drive
ORDER BY masterFiles.name
UPDATE DBA.dbo.MOVE_Servername_Log SET ToDrive = LEFT(NewLocation,1)</span></pre></div></div></p>
<p>Once the table was created we could do some analysis on how much disk space was being moved to each drive:</p>
<p><div id="wpshdo_23" class="wp-synhighlighter-outer"><div id="wpshdt_23" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_23"></a><a id="wpshat_23" class="wp-synhighlighter-title" href="#codesyntax_23"  onClick="javascript:wpsh_toggleBlock(23)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_23" onClick="javascript:wpsh_code(23)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_23" onClick="javascript:wpsh_print(23)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_23" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="co1">-- Get disk space totals ----------------------------------------------------------</span>
<span class="kw1">SELECT</span> ToDrive, <span class="kw1">CASE</span> FileType <span class="kw1">WHEN</span> <span class="st0">'ROWS'</span> <span class="kw1">THEN</span> <span class="st0">'DATA'</span> <span class="kw1">ELSE</span> FileType <span class="kw1">END</span> <span class="kw1">AS</span> FileType, <span class="kw2">SUM</span><span class="br0">&#40;</span>size_MB<span class="br0">&#41;</span> <span class="kw1">AS</span> MBPerDrive
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> FromDrive <span class="sy0">!=</span> ToDrive
    <span class="kw1">GROUP</span> <span class="kw1">BY</span> ToDrive, FileType
<span class="kw1">UNION</span>
<span class="kw1">SELECT</span> ToDrive, <span class="st0">'All'</span> <span class="kw1">AS</span> FileType, <span class="kw2">SUM</span><span class="br0">&#40;</span>size_MB<span class="br0">&#41;</span> <span class="kw1">AS</span> MBPerDrive
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> FromDrive <span class="sy0">!=</span> ToDrive
    <span class="kw1">GROUP</span> <span class="kw1">BY</span> ToDrive
<span class="kw1">UNION</span>
<span class="kw1">SELECT</span> <span class="st0">'---- Total'</span> <span class="kw1">AS</span> ToDrive, <span class="st0">'All'</span> <span class="kw1">AS</span> FileType, <span class="kw2">SUM</span><span class="br0">&#40;</span>size_MB<span class="br0">&#41;</span> <span class="kw1">AS</span> MBPerDrive
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> FromDrive <span class="sy0">!=</span> ToDrive
<span class="kw1">ORDER</span> <span class="kw1">BY</span> ToDrive <span class="kw1">DESC</span>,FileType <span class="kw1">DESC</span></pre></div></div></p>
<p>Once the analysis was done, we were ready create our move script. Since we were moving both system and user databases, we wanted to script and move them separately.  We decided to use the ALTER DATABASE method rather than the DETACH/ATTACH method described above. So, for the system database files, the commands would be as follows:</p>
<p><div id="wpshdo_24" class="wp-synhighlighter-outer"><div id="wpshdt_24" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_24"></a><a id="wpshat_24" class="wp-synhighlighter-title" href="#codesyntax_24"  onClick="javascript:wpsh_toggleBlock(24)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_24" onClick="javascript:wpsh_code(24)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_24" onClick="javascript:wpsh_print(24)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_24" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>master<span class="br0">]</span> <span class="kw1">MODIFY</span> <span class="kw1">FILE</span> <span class="br0">&#40;</span>NAME <span class="sy0">=</span> master,
    FILENAME <span class="sy0">=</span> <span class="st0">'G:<span class="es0">\S</span>QL_MDF_SYSTEM_DATA<span class="es0">\m</span>aster.mdf'</span> <span class="br0">&#41;</span>
<span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>master<span class="br0">]</span> <span class="kw1">MODIFY</span> <span class="kw1">FILE</span> <span class="br0">&#40;</span>NAME <span class="sy0">=</span> mastlog,
    FILENAME <span class="sy0">=</span> <span class="st0">'F:<span class="es0">\S</span>QL_LDF_SYSTEM_DATA<span class="es0">\m</span>astlog.ldf'</span> <span class="br0">&#41;</span></pre></div></div></p>
<p>Then shutdown SQL Server, copy the physical files to the new locations, and restart SQL Server.</p>
<p>IMPORTANT: Before moving any database files, make sure that the SQL Server Services login has permissions in each of the directories.</p>
<p>The user databases will be similar but rather than taking SQL Server down, you take each of the databases offline, move the physical files, then bring the databases back online. You may have to create or download a script for killing connections, but that is not provided here.</p>
<p><div id="wpshdo_25" class="wp-synhighlighter-outer"><div id="wpshdt_25" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_25"></a><a id="wpshat_25" class="wp-synhighlighter-title" href="#codesyntax_25"  onClick="javascript:wpsh_toggleBlock(25)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_25" onClick="javascript:wpsh_code(25)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_25" onClick="javascript:wpsh_print(25)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_25" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>AdventureWorks2012<span class="br0">]</span> <span class="kw1">MODIFY</span> <span class="kw1">FILE</span> <span class="br0">&#40;</span>NAME <span class="sy0">=</span> <span class="br0">[</span>AdventureWorks2012_Data<span class="br0">]</span>, FILENAME <span class="sy0">=</span> <span class="st0">'G:<span class="es0">\S</span>QL_MDF_DATA<span class="es0">\A</span>dventureWorks2012_Data.mdf'</span> <span class="br0">&#41;</span>
<span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>AdventureWorks2012<span class="br0">]</span> <span class="kw1">MODIFY</span> <span class="kw1">FILE</span> <span class="br0">&#40;</span>NAME <span class="sy0">=</span> <span class="br0">[</span>AdventureWorks2012_Log<span class="br0">]</span>, FILENAME <span class="sy0">=</span> <span class="st0">'F:<span class="es0">\S</span>QL_LDF_DATA<span class="es0">\A</span>dventureWorks2012_log.ldf'</span> <span class="br0">&#41;</span>
<span class="kw1">ALTER</span> <span class="kw1">DATABASE</span> <span class="br0">[</span>AdventureWorks2012<span class="br0">]</span> <span class="kw1">SET</span> OFFL<span class="sy0">IN</span>E</pre></div></div></p>
<p>For the script creation, we created a temporary table with database name, sort order (so commands display in correct order), and the actual script command. Also, we wanted to script out the robocopy commands for the physical moves, so we defined a log file:</p>
<p><div id="wpshdo_26" class="wp-synhighlighter-outer"><div id="wpshdt_26" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_26"></a><a id="wpshat_26" class="wp-synhighlighter-title" href="#codesyntax_26"  onClick="javascript:wpsh_toggleBlock(26)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_26" onClick="javascript:wpsh_code(26)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_26" onClick="javascript:wpsh_print(26)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_26" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="co1">-- Define the location and name of the robocopy log</span>
<span class="kw1">DECLARE</span>	 @robocopyLog		<span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="st0">'G:<span class="es0">\M</span>SSQL<span class="es0">\r</span>obocopy.log'</span></pre></div></div></p>
<p>The script was built as follows:</p>
<p><div id="wpshdo_27" class="wp-synhighlighter-outer"><div id="wpshdt_27" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_27"></a><a id="wpshat_27" class="wp-synhighlighter-title" href="#codesyntax_27"  onClick="javascript:wpsh_toggleBlock(27)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_27" onClick="javascript:wpsh_code(27)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_27" onClick="javascript:wpsh_print(27)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_27" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="co1">-- Build System DB move script ------------------------------------------------------------------------</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">0</span>,<span class="st0">'--------- Begin System Database Move Script ---------------'</span><span class="br0">&#41;</span>
&nbsp;
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>DatabaseName, Sort,Script<span class="br0">&#41;</span>
    <span class="kw1">SELECT</span> <span class="kw1">DISTINCT</span> DatabaseName, <span class="nu0">1</span>,<span class="st0">'    ALTER DATABASE '</span> <span class="sy0">+</span>  <span class="kw2">QUOTENAME</span><span class="br0">&#40;</span>DatabaseName<span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">' MODIFY FILE (NAME = '</span> <span class="sy0">+</span> FileName <span class="sy0">+</span> <span class="st0">', FILENAME = '</span><span class="st0">''</span> <span class="sy0">+</span>  NewLocation <span class="sy0">+</span> <span class="st0">''</span><span class="st0">' )'</span>
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> OriginalLocation <span class="sy0">&lt;&gt;</span> NewLocation
        <span class="sy0">AND</span> DatabaseAvailable <span class="sy0">=</span> <span class="st0">'isAvailable'</span>
        <span class="sy0">AND</span> database_id <span class="sy0">&lt;=</span> 4
&nbsp;
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">2</span>,<span class="st0">'-----------------------------------------------------------'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">3</span>,<span class="st0">'-- COPY Physical files. Run the following commands in a CMD window. Run as Administrator!'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">4</span>,<span class="st0">'-----------------------------------------------------------'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>DatabaseName, Sort, Script<span class="br0">&#41;</span>
    <span class="kw1">SELECT</span> <span class="kw1">DISTINCT</span> DatabaseName, <span class="nu0">5</span>,<span class="st0">'    robocopy &quot;'</span> 
        <span class="sy0">+</span> OriginalDir <span class="sy0">+</span> <span class="st0">'&quot; &quot;'</span> 
        <span class="sy0">+</span> NewLocationDir <span class="sy0">+</span> <span class="st0">'&quot; &quot;'</span> 
        <span class="sy0">+</span> PhysFileName <span class="sy0">+</span> <span class="st0">'&quot; /COPYALL /NJS /LOG+:&quot;'</span> 
        <span class="sy0">+</span> @robocopyLog <span class="sy0">+</span> <span class="st0">'&quot;'</span>
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> OriginalLocation <span class="sy0">&lt;&gt;</span> NewLocation
        <span class="sy0">AND</span> DatabaseAvailable <span class="sy0">=</span> <span class="st0">'isAvailable'</span>
        <span class="sy0">AND</span> database_id <span class="sy0">&lt;=</span> 4
&nbsp;
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">6</span>,<span class="st0">'------------------- End System Script ---------------------'</span><span class="br0">&#41;</span>
<span class="co1">-- END Build User DB move script -----------------------------------------------------------------------</span>
&nbsp;
<span class="co1">-- Build User DB move script ---------------------------------------------------------------------------</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">7</span>,<span class="st0">'------------ Begin User Database Move Script --------------'</span><span class="br0">&#41;</span>
&nbsp;
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>DatabaseName, Sort,Script<span class="br0">&#41;</span>
    <span class="kw1">SELECT</span> <span class="kw1">DISTINCT</span> DatabaseName, <span class="nu0">8</span>,<span class="st0">'    ALTER DATABASE '</span> <span class="sy0">+</span>  <span class="kw2">QUOTENAME</span><span class="br0">&#40;</span>DatabaseName<span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">' MODIFY FILE (NAME = ['</span> <span class="sy0">+</span> FileName <span class="sy0">+</span> <span class="st0">'], FILENAME = '</span><span class="st0">''</span> <span class="sy0">+</span>  NewLocation <span class="sy0">+</span> <span class="st0">''</span><span class="st0">' )'</span>
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> OriginalLocation <span class="sy0">&lt;&gt;</span> NewLocation
        <span class="sy0">AND</span> DatabaseAvailable <span class="sy0">=</span> <span class="st0">'isAvailable'</span>
        <span class="sy0">AND</span> database_id <span class="sy0">&gt;</span> 4
&nbsp;
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>DatabaseName, Sort,Script<span class="br0">&#41;</span>
    <span class="kw1">SELECT</span> <span class="kw1">DISTINCT</span> DatabaseName, <span class="nu0">8</span>,<span class="st0">'    ALTER DATABASE '</span> <span class="sy0">+</span>  <span class="kw2">QUOTENAME</span><span class="br0">&#40;</span>DatabaseName<span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">' SET OFFLINE'</span>
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> OriginalLocation <span class="sy0">&lt;&gt;</span> NewLocation
        <span class="sy0">AND</span> DatabaseAvailable <span class="sy0">=</span> <span class="st0">'isAvailable'</span>
        <span class="sy0">AND</span> database_id <span class="sy0">&gt;</span> 4
&nbsp;
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">9</span>,<span class="st0">'-----------------------------------------------------------'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">10</span>,<span class="st0">'-- COPY Physical files. Run the following commands in a CMD window. Run as Administrator!'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">11</span>,<span class="st0">'----------------------------------------------------------'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>DatabaseName, Sort, Script<span class="br0">&#41;</span>
    <span class="kw1">SELECT</span> <span class="kw1">DISTINCT</span> DatabaseName, <span class="nu0">12</span>,<span class="st0">'    robocopy &quot;'</span> 
        <span class="sy0">+</span> OriginalDir <span class="sy0">+</span> <span class="st0">'&quot; &quot;'</span> 
        <span class="sy0">+</span> NewLocationDir <span class="sy0">+</span> <span class="st0">'&quot; &quot;'</span> 
        <span class="sy0">+</span> PhysFileName <span class="sy0">+</span> <span class="st0">'&quot; /COPYALL /NJS /LOG+:&quot;'</span> 
        <span class="sy0">+</span> @robocopyLog <span class="sy0">+</span> <span class="st0">'&quot;'</span>
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> OriginalLocation <span class="sy0">&lt;&gt;</span> NewLocation
        <span class="sy0">AND</span> DatabaseAvailable <span class="sy0">=</span> <span class="st0">'isAvailable'</span>
        <span class="sy0">AND</span> database_id <span class="sy0">&gt;</span> 4
&nbsp;
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">13</span>,<span class="st0">'----------------------------------------------------------'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">14</span>,<span class="st0">'-- Bring the databases back online.'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">15</span>,<span class="st0">'----------------------------------------------------------'</span><span class="br0">&#41;</span>
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>DatabaseName, Sort, Script<span class="br0">&#41;</span>
    <span class="kw1">SELECT</span> <span class="kw1">DISTINCT</span> DatabaseName, <span class="nu0">16</span>,<span class="st0">'    ALTER DATABASE '</span> <span class="sy0">+</span>  <span class="kw2">QUOTENAME</span><span class="br0">&#40;</span>DatabaseName<span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">' SET ONLINE'</span>
    <span class="kw1">FROM</span> DBA.<span class="me1">dbo</span>.<span class="me1">MOVE_Servername_Log</span>
    <span class="kw1">WHERE</span> OriginalLocation <span class="sy0">&lt;&gt;</span> NewLocation
        <span class="sy0">AND</span> DatabaseAvailable <span class="sy0">=</span> <span class="st0">'isAvailable'</span>
        <span class="sy0">AND</span> database_id <span class="sy0">&gt;</span> 4
&nbsp;
<span class="kw1">INSERT</span> <span class="kw1">INTO</span> ##Script<span class="br0">&#40;</span>Sort,Script<span class="br0">&#41;</span> <span class="kw1">VALUES</span> <span class="br0">&#40;</span><span class="nu0">17</span>,<span class="st0">'--------------------- End User Script --------------------'</span><span class="br0">&#41;</span>
<span class="co1">-- END Build User DB move script -----------------------------------------------------------------------</span></pre></div></div></p>
<p>Now that the script has been created in the ##Script table, you can extract it by running the following SELECT statement to a text output in SSMS:</p>
<p><div id="wpshdo_28" class="wp-synhighlighter-outer"><div id="wpshdt_28" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_28"></a><a id="wpshat_28" class="wp-synhighlighter-title" href="#codesyntax_28"  onClick="javascript:wpsh_toggleBlock(28)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_28" onClick="javascript:wpsh_code(28)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_28" onClick="javascript:wpsh_print(28)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_28" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">SELECT</span> Script
<span class="kw1">FROM</span> ##Script
<span class="kw1">ORDER</span> <span class="kw1">BY</span> Sort, DatabaseName, Script</pre></div></div></p>
<p>So in conclusion, moving multiple databases is not difficult if the task is approached with caution and plenty of forethought. The scripts and details defined herein provide one methodology for completing the task, but ultimately it is up to you to choose how you want to make this move. As always, proceed with caution!</p>
<p>The post <a href="https://sqlsolutionsgroup.com/moving-databases/">Moving Databases to New Drives: A Real-world Case Study Involving 120 Databases</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
