<?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>#parallelism #azure Archives | SQL Solutions Group</title>
	<atom:link href="https://sqlsolutionsgroup.com/tag/parallelism-azure/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlsolutionsgroup.com/tag/parallelism-azure/</link>
	<description></description>
	<lastBuildDate>Mon, 22 Dec 2025 22:05:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://sqlsolutionsgroup.com/wp-content/uploads/2021/01/cropped-SSG_FAVICON0002-32x32.png</url>
	<title>#parallelism #azure Archives | SQL Solutions Group</title>
	<link>https://sqlsolutionsgroup.com/tag/parallelism-azure/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Contained Availability Groups in SQL Server 2022: What You Need to Know</title>
		<link>https://sqlsolutionsgroup.com/contained-availability-groups-in-sql-server-2022-what-you-need-to-know/</link>
					<comments>https://sqlsolutionsgroup.com/contained-availability-groups-in-sql-server-2022-what-you-need-to-know/#respond</comments>
		
		<dc:creator><![CDATA[A.K. Gonzalez]]></dc:creator>
		<pubDate>Sat, 22 Nov 2025 19:40:40 +0000</pubDate>
				<category><![CDATA[Contained AG's]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2022]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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[availability groups]]></category>
		<category><![CDATA[contained ag]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">https://sqlsolutionsgroup.com/?p=7298</guid>

					<description><![CDATA[<p>Overview One of the more intriguing features introduced in SQL Server 2022 is Contained Availability Groups (AGs). At first glance, they look very similar to traditional AGs — but there are some key differences that can trip you up if you’re not prepared. In this post, we’ll walk through: What a normal AG looks like [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/contained-availability-groups-in-sql-server-2022-what-you-need-to-know/">Contained Availability Groups in SQL Server 2022: What You Need to Know</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1><em><span class="s1">Overview</span></em></h1>
<p class="p3"><em><strong><span class="s2">One of the more intriguing features introduced in SQL Server 2022 is </span><span class="s3">Contained Availability Groups (AGs)</span><span class="s2">. At first glance, they look very similar to traditional AGs — but there are some key differences that can trip you up if you’re not prepared.</span></strong></em></p>
<p class="p1"><span class="s1">In this post, we’ll walk through:</span></p>
<ul>
<li>
<p class="p1"><span class="s1">What a normal AG looks like (and its limitations)</span></p>
</li>
<li>
<p class="p1"><span class="s1">How Contained AGs change the game</span></p>
</li>
<li>
<p class="p1"><span class="s1">The pitfalls we’ve seen in real-world use</span></p>
</li>
<li>
<p class="p1"><span class="s1">Practical solutions if you run into these issues</span></p>
</li>
</ul>
<h2><em><span class="s1">A Quick Refresher: Always On Availability Groups</span></em></h2>
<p class="p3"><span class="s2">Availability Groups, introduced back in SQL Server 2012, are Microsoft’s built-in solution for </span><span class="s3">high availability and disaster recovery</span><span class="s2">. They let you replicate databases across multiple instances, managed by a Windows Server Failover Cluster (WSFC).</span></p>
<p class="p1"><span class="s1">Key benefits:</span></p>
<ul>
<li>
<p class="p1"><span class="s1">Seamless failover between primary and secondary nodes</span></p>
</li>
<li>
<p class="p1"><span class="s1">Read-only replicas to offload workloads</span></p>
</li>
<li>
<p class="p1"><span class="s1">The ability to perform backups and DBCC checks on secondaries, easing the load on your primary</span></p>
</li>
</ul>
<p class="p1"><span class="s1">But AGs have always had one big limitation: </span><span class="s2">only user databases are replicated.</span><span class="s1"> System databases like </span><span class="s3">msdb</span><span class="s1"> and </span><span class="s3">master</span><span class="s1"> stay local to each node.</span></p>
<p class="p1"><span class="s1">Why does that matter? Think about Agent jobs:</span></p>
<ul>
<li>
<p class="p1"><span class="s1">You have to manually install jobs on every node (and keep them in sync).</span></p>
</li>
<li>
<p class="p1"><span class="s1">Jobs need to be AG-aware — otherwise they might try to run against a read-only secondary.</span></p>
</li>
<li>
<p class="p1"><span class="s1">Job history lives only on the current primary, which makes tracking a little messy.</span></p>
</li>
</ul>
<p class="p1"><span class="s1">For years, DBAs have worked around these issues, but it’s always been a pain point.</span></p>
<h2><em><span class="s1">*Enter Contained Availability Groups*</span></em></h2>
<p class="p3"><span class="s2">Contained AGs look and act like traditional AGs, but with one important twist: they include their own </span><span class="s3">contained system databases.</span></p>
<p class="p3"><span class="s2">For example, if you create a Contained AG called </span><span class="s4">MyAg</span><span class="s2">, you’ll see:</span></p>
<ul>
<li>
<p class="p1"><span class="s1">MyAg_master</span></p>
</li>
<li>
<p class="p1"><span class="s1">MyAg_msdb</span></p>
</li>
</ul>
<p class="p3"><span class="s2">These are replicated to all nodes in the AG, just like user databases.</span></p>
<h3><span class="s1">Why this matters</span></h3>
<ul>
<li>
<p class="p1"><span class="s1">Agent jobs now live inside the contained msdb.</span><span class="s2"> No more duplicating jobs on every node.</span></p>
</li>
<li>
<p class="p1"><span class="s1">Job history is replicated.</span><span class="s2"> After failover, you don’t lose tracking.</span></p>
</li>
<li>
<p class="p1"><span class="s1">System tables travel with the AG.</span><span class="s2"> Everything stays consistent across nodes.</span></p>
</li>
</ul>
<p class="p3"><span class="s2">That’s a big win for manageability and one of the headline features of SQL Server 2022.</span></p>
<h2><em><span class="s1">Gotchas Seen in the Wild</span></em></h2>
<p class="p3"><span class="s2">As with most “new shiny” features, Contained AGs aren’t a silver bullet. There&#8217;s a few things to watch out for:</span></p>
<ol start="1">
<li>
<p class="p1"><span class="s1">No more job offloading to secondaries.</span><span class="s2"> Jobs inside the contained msdb only run on the primary. If you used secondaries to handle CHECKDB or backups, you’ll need to rethink.</span></p>
</li>
<li>
<p class="p1"><span class="s1">Replication is not supported.</span><span class="s2"> If transactional replication is part of your design, contained AGs may not be an option.</span></p>
</li>
<li>
<p class="p1"><span class="s1">Seeding is clunky.</span><span class="s2"> The GUI doesn’t support manual seeding yet. You’ll need to fall back to T-SQL.</span></p>
</li>
<li>
<p class="p1"><span class="s1">No distributed AG support.</span><span class="s2"> If you rely on DAGs for hybrid or geo-distributed HA, contained AGs won’t help.</span></p>
</li>
<li>
<p class="p1"><span class="s1">Confusion with system databases.</span><span class="s2"> When you connect to the listener, the </span><span class="s3">msdb</span><span class="s2"> and </span><span class="s3">master</span><span class="s2"> you see belong to the contained AG — not the local system copies.</span></p>
</li>
</ol>
<p>&nbsp;</p>
<h2><em><span class="s1">Workarounds &amp; Solutions</span></em></h2>
<h3><span class="s1">For Agent Jobs</span></h3>
<p class="p3"><span class="s2">If you truly need jobs to run on a secondary node, you still can — but you’ll have to install them in the </span><span class="s3">local msdb</span><span class="s2"> outside the contained AG. That means:</span></p>
<ul>
<li>
<p class="p1"><span class="s1">Jobs must be AG-aware again</span></p>
</li>
<li>
<p class="p1"><span class="s1">You’ll have to maintain them separately</span></p>
</li>
</ul>
<p class="p3"><span class="s2">It’s not elegant, but it gets the job done.</span></p>
<h3><span class="s1">For System Databases</span></h3>
<p class="p3"><span class="s2">This is case-by-case. If your code doesn’t touch </span><span class="s4">master</span><span class="s2"> or </span><span class="s4">msdb</span><span class="s2">, you’re fine. But if you do, you’ll need to carefully evaluate whether those objects belong in the contained copies or the traditional system DBs.</span></p>
<p class="p3"><span class="s2">Remember: you can query both contained and local msdbs — just make sure your scripts account for both.</span></p>
<p>&nbsp;</p>
<h2><em><span class="s1">Final Word</span></em></h2>
<p class="p3"><span class="s2">Contained Availability Groups solve one of the long-standing headaches of AGs — managing Agent jobs across nodes. But they come with trade-offs that every DBA needs to be aware of.</span></p>
<p class="p3"><span class="s2">Test carefully. Know where your jobs live. And make sure your disaster recovery plan accounts for these differences.</span></p>
<p class="p3"><span class="s2">If you want to see them in action, check out our webinar on SQL Server 2022 features, where we demo Contained AGs in detail.</span></p>
<p>The post <a href="https://sqlsolutionsgroup.com/contained-availability-groups-in-sql-server-2022-what-you-need-to-know/">Contained Availability Groups in SQL Server 2022: What You Need to Know</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/contained-availability-groups-in-sql-server-2022-what-you-need-to-know/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding Wait Stats in SQL Server: A Practical Guide</title>
		<link>https://sqlsolutionsgroup.com/understanding-wait-stats-in-sql-server-a-practical-guide/</link>
					<comments>https://sqlsolutionsgroup.com/understanding-wait-stats-in-sql-server-a-practical-guide/#respond</comments>
		
		<dc:creator><![CDATA[A.K. Gonzalez]]></dc:creator>
		<pubDate>Thu, 14 Aug 2025 20:47:34 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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">https://sqlsolutionsgroup.com/?p=7293</guid>

					<description><![CDATA[<p>When working with SQL Server, one of the best tools DBA&#8217;s can use for diagnosing performance issues is wait statistics (or wait stats for short). But what exactly are they, and how are you supposed to interpret them? In this guide, I’ll break down what wait stats are, why they matter, and how to use [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/understanding-wait-stats-in-sql-server-a-practical-guide/">Understanding Wait Stats in SQL Server: A Practical Guide</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p class="p1" style="text-align: left;"><strong><em><span class="s1">When working with SQL Server, one of the best tools DBA&#8217;s can use for diagnosing performance issues is </span><span class="s2">wait statistics</span><span class="s1"> (or </span><span class="s3">wait stats</span><span class="s1"> for short). </span></em></strong><strong><em><span class="s1">But what exactly are they, and how are you supposed to interpret them? </span></em></strong><strong><em><span class="s1">In this guide, I’ll break down what wait stats are, why they matter, and how to use them to troubleshoot performance problems. </span></em></strong></p>
<p>Thank you to our SQL Server Expert and Senior DBA, Rich Benner for providing the valuable Technical info behind this blog. To learn more about Wait Statistics from Rich, check out his recent <a href="https://www.youtube.com/watch?v=rw9il1pJtdI&amp;t=1s">webinar</a> and two new YouTube videos- an <a href="https://www.youtube.com/watch?v=IwXcIoEnauE&amp;t=518s">explainer</a> and a <a href="https://www.youtube.com/watch?v=6BBhQyKxMSQ">demo</a>, on our channel.</p>
<h2><span class="s1">What Are Wait Stats?</span></h2>
<p class="p3"><span class="s2">Anytime something inside Microsoft SQL Server is </span><span class="s3">waiting</span><span class="s2"> for a resource, it’s assigned a wait stat. For </span><span class="s2">example: </span></p>
<ul>
<li>
<p class="p1"><span class="s1">A query waiting for CPU or memory resources</span></p>
</li>
<li>
<p class="p1"><span class="s1">A query waiting to access a data object like a data page or table</span></p>
</li>
<li>
<p class="p1"><span class="s1">An internal SQL Server process waiting to complete a task</span></p>
</li>
</ul>
<p class="p3"><span class="s2">Some waits are completely normal. For example, in </span><span class="s3">Availability Groups</span><span class="s2">, certain threads simply wait to synchronize data with secondary nodes. That’s expected behavior and not necessarily a sign of trouble.</span></p>
<h3><span class="s1">Key Things to Know About Wait Stats</span></h3>
<ol start="1">
<li>
<p class="p1"><span class="s1">They’re cumulative</span><span class="s2"> – Wait times are aggregated since the last time the data was cleared, usually at the last server restart (though other events can reset them).</span></p>
</li>
<li>
<p class="p1"><span class="s1">They measure time in seconds or milliseconds</span><span class="s2"> – depending on the stat you’re viewing.</span></p>
</li>
<li>
<p class="p1"><span class="s1">They’re invaluable for troubleshooting</span><span class="s2"> – By looking at wait stats, you can quickly zero in on what’s slowing down your system.</span></p>
</li>
</ol>
<h3><span class="s1">How to Find Wait Stats</span></h3>
<p class="p3"><span class="s2">The primary DMV for retrieving wait stats is:</span></p>
<p><strong>SELECT * FROM sys.dm_os_wait_stats;</strong></p>
<p class="p1"><span class="s1">On a SQL Server 2022 instance, you might see over </span><span class="s2">1,300 different wait types</span><span class="s1">. Even seasoned DBAs only know a fraction of them by heart. </span><span class="s1">That’s where resources like the </span><span class="s2">SQLskills Wait Types Library</span><span class="s1"> come in handy. This community-maintained list covers around 95% of known waits, detailing whether they’re benign or problematic and suggesting possible resolutions.</span></p>
<h3><span class="s1">Useful Tools for Analyzing Wait Stats</span></h3>
<ul>
<li>
<p class="p1"><span class="s1"><a href="https://whoisactive.com/">sp_WhoIsActive</a></span><span class="s2"> – An enhanced version of </span><span class="s3">sp_who2</span><span class="s2"> that shows what queries are running, their process IDs, and any current waitss.</span></p>
</li>
<li>
<p class="p1"><span class="s1"><a href="https://www.brentozar.com/blitz/">sp_BlitzFirst</a></span><span class="s2"> – A free tool that captures your current wait stats along with other diagnostic information.</span></p>
</li>
<li>
<p class="p1"><span class="s1">Custom Queries</span><span class="s2"> – Many DBAs have their own scripts for retrieving &amp; formatting wait stats. A quick search for “Wait Stats query” will yield plenty of examples.</span></p>
</li>
</ul>
<h3><span class="s1">The Top 5 Most Common Wait Types </span></h3>
<h3><span class="s1">1. </span><span class="s1">LCK_</span><span class="s1">* – Lock Waits</span></h3>
<p class="p3"><span class="s2">Occurs when one query locks a resource (e.g., a data page) and another query has to wait for it to be released. </span><span class="s2">Example: An </span><span class="s3">UPDATE</span><span class="s2"> query locks a row, preventing a </span><span class="s3">SELECT</span><span class="s2"> query from reading it until the update completes.</span></p>
<h3><span class="s1">2. </span></h3>
<h3><span class="s1">CXPACKET / CXCONSUMER</span></h3>
<h3><span class="s1"> – Parallelism Waits</span></h3>
<p class="p3"><span class="s2">Happens when a query is split across multiple CPU cores. If one thread finishes before the others, it waits for the slowest one to catch up. </span><span class="s2">Normal in moderation, but excessive CX waits can indicate an inefficient parallelism setup.</span></p>
<h3><span class="s1">3. </span></h3>
<h3><span class="s1">ASYNC_NETWORK_IO </span></h3>
<h3><span style="font-size: 16px;">– Application Processing Delays</span></h3>
<p class="p3"><span class="s2">Indicates SQL Server has finished processing results but is waiting for the application to consume them. </span><span class="s2">Often caused by applications retrieving rows one at a time instead of in batches.</span></p>
<h3><span class="s1">4. </span></h3>
<h3><span class="s1">LATCH_</span><span class="s1">* and </span><span class="s1">PAGE_LATCH_</span><span class="s1">* – Structure &amp; Page Locks</span></h3>
<ul>
<li>
<p class="p1"><span class="s1">LATCH_</span><span class="s2">*: Locks on internal structures (not data pages)</span></p>
</li>
<li>
<p class="p1"><span class="s1">PAGE_LATCH_</span><span class="s2">*: Locks on data pages themselves. </span><span class="s2">These can signal contention in memory structures or data access patterns.</span></p>
</li>
</ul>
<h3><span class="s1">5. </span></h3>
<h3><span class="s1">WRITELOG</span></h3>
<h3><span class="s1"> – Transaction Log Bottlenecks</span></h3>
<p class="p3"><span class="s2">This occurs when SQL Server is waiting to write to the transaction log. </span><span class="s2">Common causes include slow disk performance, excessive write activity, or log file contention.</span></p>
<p>&nbsp;</p>
<h2><span class="s1">Why Wait Stats Matter</span></h2>
<p class="p3"><span class="s2">Wait stats provide a </span><span class="s3">high-level overview</span><span class="s2"> of where SQL Server is spending its time waiting.</span></p>
<p class="p3"><span class="s2">They help you answer questions like:</span></p>
<ul>
<li>
<p class="p1"><span class="s1">Is my performance issue due to locking, disk speed, or parallelism?</span></p>
</li>
<li>
<p class="p1"><span class="s1">Is the problem in SQL Server or in the application consuming data?</span></p>
</li>
<li>
<p class="p1"><span class="s1">Are my hardware resources (CPU, memory, storage) configured optimally?</span></p>
</li>
</ul>
<p class="p3"><span class="s2">By combining wait stats with tools like </span><span class="s4">sp_WhoIsActive</span><span class="s2"> and </span><span class="s4">sp_BlitzFirst</span><span class="s2">, you can pinpoint bottlenecks faster and focus your tuning efforts where they’ll make the biggest impact. </span><span class="s1">Not all waits are bad — many are just part of normal SQL Server operations. The key is knowing </span><span class="s2">which waits are worth investigating</span><span class="s1"> and which you can safely ignore. </span><span class="s1">With a solid understanding of wait stats, you’ll be better equipped to diagnose issues, improve query performance, and keep your SQL Server running smoothly.</span></p>
<p class="p1"><strong><em><span class="s1">Need help interpreting your wait stats?</span></em></strong></p>
<p class="p1"><span class="s2">At SQL Solutions Group, we work with clients every day to identify and fix performance issues. <a href="https://sqlsolutionsgroup.com/contact/">Contact us</a> for a health check and start optimizing your environment today.</span></p>
<p>The post <a href="https://sqlsolutionsgroup.com/understanding-wait-stats-in-sql-server-a-practical-guide/">Understanding Wait Stats in SQL Server: A Practical Guide</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/understanding-wait-stats-in-sql-server-a-practical-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Safeguarding Your Data: Navigating SQL Backup, Compliance, Maintenance, and Support Challenges</title>
		<link>https://sqlsolutionsgroup.com/safeguarding-your-data-navigating-sql-backup-compliance-maintenance-and-support-challenges/</link>
					<comments>https://sqlsolutionsgroup.com/safeguarding-your-data-navigating-sql-backup-compliance-maintenance-and-support-challenges/#respond</comments>
		
		<dc:creator><![CDATA[A.K. Gonzalez]]></dc:creator>
		<pubDate>Fri, 30 May 2025 19:36:51 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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[Christmas]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">https://sqlsolutionsgroup.com/?p=7257</guid>

					<description><![CDATA[<p>As businesses become increasingly data-driven, the role of SQL databases has become critical to day-to-day operations. Yet, many organizations underestimate the ongoing demands of managing these systems securely and efficiently. In this article, we dive into four often overlooked—but vital—areas of SQL database management: backup and recovery, compliance and governance, maintenance and upgrades, and the [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/safeguarding-your-data-navigating-sql-backup-compliance-maintenance-and-support-challenges/">Safeguarding Your Data: Navigating SQL Backup, Compliance, Maintenance, and Support Challenges</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="7257" class="elementor elementor-7257" data-elementor-post-type="post">
						<section class="elementor-section elementor-top-section elementor-element elementor-element-33a15772 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="33a15772" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-28a67839" data-id="28a67839" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-39cc616 elementor-widget elementor-widget-text-editor" data-id="39cc616" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p data-start="191" data-end="633">As businesses become increasingly data-driven, the role of SQL databases has become critical to day-to-day operations. Yet, many organizations underestimate the ongoing demands of managing these systems securely and efficiently. In this article, we dive into four often overlooked—but vital—areas of SQL database management: backup and recovery, compliance and governance, maintenance and upgrades, and the need for skilled technical support.</p>
<h3 data-start="635" data-end="691">1. Backup and Recovery: Preparing for the Unexpected</h3>
<p data-start="693" data-end="767">Every company <em data-start="707" data-end="715">thinks</em> they have a backup plan—until something goes wrong.</p>
<p data-start="769" data-end="963">Backups are your first line of defense against data loss caused by system failures, human error, cyberattacks, or natural disasters. But it’s not enough to just schedule backups and forget them.</p>
<p data-start="965" data-end="984"><strong data-start="965" data-end="983">Key challenges</strong>:</p>
<ul data-start="985" data-end="1202">
<li data-start="985" data-end="1070">
<p data-start="987" data-end="1070"><strong data-start="987" data-end="1019">Incomplete backup strategies</strong> (e.g., only full backups with no transaction logs)</p>
</li>
<li data-start="1071" data-end="1121">
<p data-start="1073" data-end="1121"><strong data-start="1073" data-end="1110">Backups stored on the same server</strong> that fails</p>
</li>
<li data-start="1122" data-end="1202">
<p data-start="1124" data-end="1202"><strong data-start="1124" data-end="1147">Unverified restores</strong>—you don’t know if the backups work until you need them</p>
</li>
</ul>
<p data-start="1204" data-end="1223"><strong data-start="1204" data-end="1222">Best practices</strong>:</p>
<ul data-start="1224" data-end="1439">
<li data-start="1224" data-end="1297">
<p data-start="1226" data-end="1297">Use a layered approach: full, differential, and transaction log backups</p>
</li>
<li data-start="1298" data-end="1372">
<p data-start="1300" data-end="1372">Store backups in geographically redundant locations, including the cloud</p>
</li>
<li data-start="1373" data-end="1439">
<p data-start="1375" data-end="1439">Regularly test restores—don’t assume your backups are functional</p>
</li>
</ul>
<p data-start="1441" data-end="1575">A tested, well-architected backup and recovery plan ensures business continuity and protects your company from catastrophic data loss.</p>
<h3 data-start="1577" data-end="1637">2. Compliance and Governance: Meeting Industry Standards</h3>
<p data-start="1639" data-end="1756">With growing scrutiny around data privacy and security, compliance isn’t optional—it’s a legal and ethical necessity.</p>
<p data-start="1758" data-end="1780"><strong data-start="1758" data-end="1779">Common challenges</strong>:</p>
<ul data-start="1781" data-end="1947">
<li data-start="1781" data-end="1860">
<p data-start="1783" data-end="1860">Navigating complex regulations like <strong data-start="1819" data-end="1827">GDPR</strong>, <strong data-start="1829" data-end="1838">HIPAA</strong>, <strong data-start="1840" data-end="1847">SOX</strong>, or <strong data-start="1852" data-end="1860">CCPA</strong></p>
</li>
<li data-start="1861" data-end="1909">
<p data-start="1863" data-end="1909">Inadequate <strong data-start="1874" data-end="1890">audit trails</strong> or change tracking</p>
</li>
<li data-start="1910" data-end="1947">
<p data-start="1912" data-end="1947">Poor <strong data-start="1917" data-end="1947">role-based access controls</strong></p>
</li>
</ul>
<p data-start="1949" data-end="1976"><strong data-start="1949" data-end="1975">Why governance matters</strong>:</p>
<ul data-start="1977" data-end="2138">
<li data-start="1977" data-end="2034">
<p data-start="1979" data-end="2034">It builds customer trust and safeguards your reputation</p>
</li>
<li data-start="2035" data-end="2083">
<p data-start="2037" data-end="2083">It protects you from legal penalties and fines</p>
</li>
<li data-start="2084" data-end="2138">
<p data-start="2086" data-end="2138">It supports internal transparency and accountability</p>
</li>
</ul>
<p data-start="2140" data-end="2307">A mature SQL environment includes automated audit logs, encryption protocols, clearly defined user roles, and documented policies to handle sensitive data responsibly.</p>
<h3 data-start="2309" data-end="2365">3. Maintenance and Upgrades: Avoiding Technical Debt</h3>
<p data-start="2367" data-end="2514">SQL Server isn’t a “set it and forget it” system. Ongoing maintenance is essential to keeping your environment secure, efficient, and future-ready.</p>
<p data-start="2516" data-end="2546"><strong data-start="2516" data-end="2545">Risks of poor maintenance</strong>:</p>
<ul data-start="2547" data-end="2772">
<li data-start="2547" data-end="2639">
<p data-start="2549" data-end="2639">Performance degradation over time due to bloated indexes, fragmentation, or outdated stats</p>
</li>
<li data-start="2640" data-end="2701">
<p data-start="2642" data-end="2701">Missed patches that leave you open to known vulnerabilities</p>
</li>
<li data-start="2702" data-end="2772">
<p data-start="2704" data-end="2772">Falling behind on SQL Server versions, creating compatibility issues</p>
</li>
</ul>
<p data-start="2774" data-end="2805"><strong data-start="2774" data-end="2804">Smart maintenance includes</strong>:</p>
<ul data-start="2806" data-end="3012">
<li data-start="2806" data-end="2848">
<p data-start="2808" data-end="2848">Regular index and statistics maintenance</p>
</li>
<li data-start="2849" data-end="2899">
<p data-start="2851" data-end="2899">Applying critical patches and cumulative updates</p>
</li>
<li data-start="2900" data-end="2953">
<p data-start="2902" data-end="2953">Scheduled downtime for proactive performance tuning</p>
</li>
<li data-start="2954" data-end="3012">
<p data-start="2956" data-end="3012">Planning for version upgrades before end-of-life support</p>
</li>
</ul>
<p data-start="3014" data-end="3121">Ignoring maintenance is like skipping oil changes—eventually, your engine (or server) will grind to a halt.</p>
<h3 data-start="3123" data-end="3191">4. Technical Support and Expertise: When You Need a Second Brain</h3>
<p data-start="3193" data-end="3317">Even with strong internal IT teams, SQL Server can throw curveballs. That’s where expert-level support makes the difference.</p>
<p data-start="3319" data-end="3346"><strong data-start="3319" data-end="3345">Why companies struggle</strong>:</p>
<ul data-start="3347" data-end="3530">
<li data-start="3347" data-end="3417">
<p data-start="3349" data-end="3417">DBAs wear too many hats and don’t have time for deep problem-solving</p>
</li>
<li data-start="3418" data-end="3475">
<p data-start="3420" data-end="3475">Complex issues require years of SQL-specific experience</p>
</li>
<li data-start="3476" data-end="3530">
<p data-start="3478" data-end="3530">Emergency situations demand fast, accurate solutions</p>
</li>
</ul>
<p data-start="3532" data-end="3567"><strong data-start="3532" data-end="3566">Benefits of expert SQL support</strong>:</p>
<ul data-start="3568" data-end="3757">
<li data-start="3568" data-end="3624">
<p data-start="3570" data-end="3624">Quick diagnosis of performance or configuration issues</p>
</li>
<li data-start="3625" data-end="3692">
<p data-start="3627" data-end="3692">Help with high-availability setups and disaster recovery planning</p>
</li>
<li data-start="3693" data-end="3757">
<p data-start="3695" data-end="3757">Optimization strategies tailored to your business and workload</p>
</li>
</ul>
<p data-start="3759" data-end="3882">Partnering with seasoned SQL professionals gives your team the support it needs—without the cost of a full-time specialist.</p>
<hr data-start="3884" data-end="3887" />
<h2 data-start="3889" data-end="3906">Final Thoughts</h2>
<p data-start="3908" data-end="4224">SQL Server is a powerful engine, but like any high-performance machine, it requires care, precision, and expertise to run at its best. By prioritizing backup and recovery, ensuring compliance and governance, staying on top of maintenance, and investing in expert support, you can protect your data—and your business.</p>
<p data-start="3908" data-end="4224"> </p>
<p data-start="3908" data-end="4224">SQL Backup and Recovery, Database Compliance, SQL Governance, SQL Server Maintenance, SQL Upgrades, SQL Technical Support, SQL DBA Services, SQL Performance, SQL Disaster Recovery, Enterprise Database Management</p>


<p></p>
								</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		<p>The post <a href="https://sqlsolutionsgroup.com/safeguarding-your-data-navigating-sql-backup-compliance-maintenance-and-support-challenges/">Safeguarding Your Data: Navigating SQL Backup, Compliance, Maintenance, and Support Challenges</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/safeguarding-your-data-navigating-sql-backup-compliance-maintenance-and-support-challenges/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Copying Databases Across SQL Managed Instances</title>
		<link>https://sqlsolutionsgroup.com/copying-databases-across-sql-managed-instances/</link>
					<comments>https://sqlsolutionsgroup.com/copying-databases-across-sql-managed-instances/#comments</comments>
		
		<dc:creator><![CDATA[Scott Klein]]></dc:creator>
		<pubDate>Tue, 23 Apr 2024 11:38:47 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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[Christmas]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">https://sqlsolutionsgroup.com/?p=7024</guid>

					<description><![CDATA[<p>It only seems like yesterday since it was my turn to write a blog. And yet, here we are again, still staring at the M&#38;M dispenser full of dark chocolate peanut M&#38;Ms. (In my last blog I called it a carousel, when in reality, it is more like a Ferris wheel.) Anyway, in this blog [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/copying-databases-across-sql-managed-instances/">Copying Databases Across SQL Managed Instances</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>It only seems like yesterday <a href="https://sqlsolutionsgroup.com/the-right-tool-for-the-right-job/">since it was my turn</a> to write a blog. And yet, here we are again, still staring at the M&amp;M dispenser full of dark chocolate peanut M&amp;Ms. (In my last blog I called it a carousel, when in reality, it is more like a Ferris wheel.)</p>



<p>Anyway, in this blog post I want to cover a technology for copying databases across SQL Managed Instances that saved my posterior recently. Well, it didn’t really save it, but it sure made my life easier. We have a client who uses Azure SQL Managed Instance for both their production and test environments. I think this is awesome.</p>



<p>As a quick background, Azure SQL Managed Instance is a full SQL Server instance served up as a PaaS service. Unlike Azure SQL Database where you are only working at the database level, Managed Instance gives you near 100% instance compatibility level capabilities with the latest version of SQL Server Enterprise Edition SQL Server database engine. SQL Managed Instance provides the lift and shift capabilities of on-premises databases with minimal database changes.</p>



<p>So, back to our customer. They essentially lifted and shifted their on-premises databases to Azure SQL Managed Instance and have been using it successfully for nearly two years. Again, this is awesome.</p>



<p>Last week they came to us and asked about reporting with Managed Instance. They were looking at data marts and data warehouses, but we needed more information. It turns out they have some people that just want the ability to query the databases, and potentially hook up Excel to these databases for data analysis.</p>



<p>The caveat is that the people I was talking to didn’t want to give the other group direct access to the production environment. <em>Toootally</em> get that. Yeah, like 100% get it. So, what are the options?</p>



<p>After some discussion we decided to give the group wanting to run reports access to the test Managed Instance environment. We’ll just refresh the test environment data with the production environment data on a schedule. For them, refreshing data nightly is OK for now.</p>



<p>So, the question then becomes, how do you get data, or copy a database, from one SQL Managed Instance to another SQL Managed Instance? There are two ways, and I’ll discuss both here.</p>



<h3 class="wp-block-heading">PowerShell cmdlets</h3>



<p>Microsoft released some Powershell cmdlets that make copying data across SQL Managed Instances simple.</p>



<p>There are essentially 3 cmdlets:</p>



<ul class="wp-block-list">
<li><strong>Copy-AzSqlInstanceDatabase</strong> – Starts an online copy operation.</li>



<li><strong>Get-AzSqlInstanceDatabaseCopyOperation</strong> – Returns copy operation details.</li>



<li><strong>Complete-AzSqlInstanceDatabaseCopy</strong> – Completes the copy operation.</li>
</ul>



<p>The <em>Copy-AzSqlInstancesDatabase</em> cmdlet starts an online copy operation of a database across managed instances using Always On availability group technology. <a href="https://learn.microsoft.com/en-us/powershell/module/az.sql/copy-azsqlinstancedatabase?view=azps-11.4.0">Copy-AzSqlInstanceDatabase (Az.Sql) | Microsoft Learn</a></p>



<p>The <em>Get-AzSqlInstanceDatabaseCopyOperation</em> cmdlet returns database copy operation details. You can call this cmdlet in a loop so you can track the status of the copy. <a href="https://learn.microsoft.com/en-us/powershell/module/az.sql/get-azsqlinstancedatabasecopyoperation?view=azps-11.4.0">Get-AzSqlInstanceDatabaseCopyOperation (Az.Sql) | Microsoft Learn</a></p>



<p>The <em>Complete-AzSqlInstanceDAtabaseCopy</em> cmdlet completes the copy operation of the database and makes it available for read/write workloads. <a href="https://learn.microsoft.com/en-us/powershell/module/az.sql/complete-azsqlinstancedatabasecopy?view=azps-11.4.0">Complete-AzSqlInstanceDatabaseCopy (Az.Sql) | Microsoft Learn</a></p>



<p>You don’t have to call the <em>Get-AzSqlInstanceDatabaseCopyOperation</em> cmdlet as you could just call the Copy and Complete, but it is HIGHLY recommended you call it so you know when to call the complete.</p>



<p>The way this works is you start by calling the <em>Copy-AzSqlInstancesDatabase</em> cmdlet. This starts an online copy operation of one or more databases. Once the copy option starts, data is being seeded from the source to the target. During the process, you can call the <em>Get-AzSqlInstanceDatabaseCopyOperation</em> cmdlet to check the copy operation status, either in-progress or completed.</p>



<p>Once the copy operation has completed, the status will be copy ready for completion. Within the next 24 hours the user can complete the database copy operation by calling the <em>Get-AzSqlInstanceDatabaseCopyOperation</em> cmdlet. Note that until the <em>Get-AzSqlInstanceDatabaseCopyOperation</em> cmdlet is called, all the changes from the source are being replicated to the target database.</p>



<p>When <em>Get-AzSqlInstanceDatabaseCopyOperation</em> is called, the link between the source and target databases is broken, the target database becomes online and ready.</p>



<p>A very simple example would be something like this:</p>



<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="powershell" style="font-family:monospace;"><span class="re0">$dbname</span> <span class="sy0">=</span> <span class="st0">&quot;db1&quot;</span>
<span class="re0">$sourceMI</span> <span class="sy0">=</span> <span class="st0">&quot;sqlmi1&quot;</span>
<span class="re0">$targetMI</span> <span class="sy0">=</span> <span class="st0">&quot;sqlmi2&quot;</span>
<span class="re0">$sourceRG</span> <span class="sy0">=</span> <span class="st0">&quot;rg1&quot;</span>
<span class="re0">$targetMI</span> <span class="sy0">=</span> <span class="st0">&quot;rg2&quot;</span>
&nbsp;
Copy<span class="sy0">-</span>AzSqlInstanceDatabase `
    <span class="sy0">-</span>DatabaseName <span class="re0">$dbName</span> `
    <span class="sy0">-</span>InstanceName <span class="re0">$sourceMi</span> `
    <span class="sy0">-</span>ResourceGroupName <span class="re0">$sourceRg</span> `
    <span class="sy0">-</span>TargetInstanceName <span class="re0">$targetMi</span> `
    <span class="sy0">-</span>TargetResourceGroupName <span class="re0">$targetRg</span> 
&nbsp;
<span class="kw3">While</span><span class="br0">&#40;</span>true$<span class="br0">&#41;</span>
<span class="br0">&#123;</span>
&nbsp;
    <span class="kw1">Start-Sleep</span> <span class="kw5">-Seconds</span> 10
    <span class="re0">$operation</span> <span class="sy0">=</span> Get<span class="sy0">-</span>AzSqlInstanceDatabaseCopyOperation `
    <span class="sy0">-</span>DatabaseName <span class="re0">$dbname</span> `
    <span class="sy0">-</span>InstanceName <span class="re0">$sourceMI</span> `
    <span class="sy0">-</span>ResourceGroupName <span class="re0">$sourceRG</span> `
    <span class="sy0">-</span>TargetInstanceName <span class="re0">$targetMI</span> `
    <span class="sy0">-</span>TargetResourceGroupName <span class="re0">$targetRG</span>
&nbsp;
    try
    <span class="br0">&#123;</span>
        <span class="re0">$copysucceeded</span> <span class="sy0">=</span> <span class="re0">$true</span>
        <span class="kw1">Write-Host</span> <span class="st0">&quot;Status of copy for &quot;</span> <span class="re0">$dbname</span> <span class="st0">&quot; is &quot;</span> <span class="re0">$operation</span>.State
        <span class="kw3">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="br0">&#40;</span><span class="re0">$operation</span>.State <span class="kw4">-eq</span> <span class="st0">&quot;Succeeded&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="re0">$copysucceeded</span> <span class="sy0">=</span> <span class="re0">$false</span>;<span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
    catch <span class="br0">&#123;</span> <span class="re0">$copysucceeded</span> <span class="sy0">=</span> <span class="re0">$false</span>; <span class="kw1">Write-Host</span> <span class="st0">&quot;Didn't work&quot;</span> <span class="br0">&#125;</span>
&nbsp;
    <span class="kw3">if</span> <span class="br0">&#40;</span><span class="re0">$copysucceeded</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="kw1">Write-Host</span> <span class="st0">&quot;Copy completed&quot;</span>
        <span class="kw3">break</span>
    <span class="br0">&#125;</span>
    <span class="kw3">else</span> <span class="br0">&#123;</span> <span class="kw1">Write-Host</span> <span class="st0">&quot;Still copying...&quot;</span> <span class="br0">&#125;</span>
&nbsp;
<span class="br0">&#125;</span>
&nbsp;
Complete<span class="sy0">-</span>AzSqlInstanceDatabaseCopy `
    <span class="sy0">-</span>DatabaseName <span class="re0">$dbName</span> `
    <span class="sy0">-</span>InstanceName <span class="re0">$sourceMI</span> `
    <span class="sy0">-</span>ResourceGroupName <span class="re0">$sourceRG</span> `
    <span class="sy0">-</span>TargetInstanceName <span class="re0">$targetMI</span> `
    <span class="sy0">-</span>TargetResourceGroupName $targetRG</pre></div></div>



<p>There is a GREAT example here: <a href="https://techcommunity.microsoft.com/t5/azure-sql-blog/how-to-automate-azure-sql-managed-instance-database-copy-and/ba-p/3874505">Using and automating Azure SQL Managed Instance database copy and database move operations with Azure PowerShell (microsoft.com)</a></p>



<p>The example copies multiple databases, but if you are needing to copy only one, you can tweak it.</p>



<p>Oh, by the way, you can also do the copy via the Azure portal.</p>



<figure class="wp-block-image size-full is-resized"><img fetchpriority="high" decoding="async" width="450" height="228" class="wp-image-7038" style="width: 450px;" src="https://sqlsolutionsgroup.com/wp-content/uploads/2024/04/image.png" alt="" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2024/04/image.png 535w, https://sqlsolutionsgroup.com/wp-content/uploads/2024/04/image-300x152.png 300w" sizes="(max-width: 450px) 100vw, 450px" /></figure>



<h3 class="wp-block-heading">Backup / Restore</h3>



<p>The other option is backup and restore, meaning, back up to Azure blob storage then restore from there. Since Managed Instance provides access to the SQL Agent, a job is created on both managed instances; one to back up, and one to restore.</p>



<p>This option gets a bit tricky because in the scenario for our client, and I would think in most environments, you want to restore the database in the target managed instance with the same name, and have the backup file the same as well, just to make it easy.</p>



<p>The backup job is simple: back up the database to Azure, ensuring the backup file name is always the same name. The restore job is just as simple: delete the database and then restore the database with the same name.</p>



<p>However, the issue in this scenario is that when you back up to the same file name, it will error because the file already exists. When we tested we thought, “no problem, we’ll just use PowerShell (Remove-AzureStorageBlob) to remove the file as the first step in the job, then the second step in the job will be to back up the database!”</p>



<p>Unfortunately, Managed Instance does not support PowerShell job steps. Sigh. So, we have an on-premises job (or it can even be a Windows Task Scheduler job) that runs the delete. At this point it is just a timing thing. Since the client only wants to back up and restore a single database, we run the backup job at 1 a.m., for example. Then 30 minutes later we run the restore, then another 30 minutes later, we run the delete blob job.</p>
<p>For this solution you’ll need to create a storage account in Azure, then create a CREDENTIAL in SQL Server on both Managed Instances:</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="powershell" style="font-family:monospace;">CREATE CREDENTIAL <span class="br0">[</span>https:<span class="sy0">//</span>mystorageaccount.blob.core.windows.net<span class="sy0">/</span>mycontainer<span class="br0">]</span>
WITH IDENTITY N<span class="st0">'SHARED ACCESS SIGNATURE'</span><span class="sy0">,</span>
SECRET <span class="sy0">=</span> N<span class="st0">'&lt;storageaccountkey&gt;'</span></pre></div></div>



<p>Once that is created, simply back up the database.</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="powershell" style="font-family:monospace;">BACKUP DATABASE <span class="br0">[</span>MyDB<span class="br0">]</span> TO URL <span class="sy0">=</span> N<span class="st0">'https://mystorageaccount.blob.core.windows.net/mycontainer/MyDB.bak'</span>
	WITH BLOCKSIZE <span class="sy0">=</span> <span class="nu0">65535</span><span class="sy0">,</span> COPY_ONLY<span class="sy0">,</span> NOFORMAT<span class="sy0">,</span> NOINIT<span class="sy0">,</span> 
	NAME <span class="sy0">=</span> N<span class="st0">'MyDB-Full Database Backup'</span><span class="sy0">,</span> NOSKIP<span class="sy0">,</span> NOREWIND<span class="sy0">,</span> NOUNLOAD<span class="sy0">,</span> STATS <span class="sy0">=</span> <span class="nu0">10</span></pre></div></div>
<p>Or, if you are using Ola Hallengren’s solution (which we are a major fan of):</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="powershell" style="font-family:monospace;">EXECUTE <span class="br0">[</span>dbo<span class="br0">]</span>.<span class="br0">[</span>DatabaseBackup<span class="br0">]</span>
<span class="sy0">@</span>Databases <span class="sy0">=</span> <span class="st0">'SentryOne'</span><span class="sy0">,</span>
<span class="sy0">@</span>URL <span class="sy0">=</span> <span class="st0">'https://mystorageaccount.blob.core.windows.net/mycontainer'</span><span class="sy0">,</span>
<span class="sy0">@</span>Credential <span class="sy0">=</span> <span class="st0">'https://mystorageaccount.blob.core.windows.net/mycontainer'</span><span class="sy0">,</span>
<span class="sy0">@</span>BackupType <span class="sy0">=</span> <span class="st0">'FULL'</span><span class="sy0">,</span>
<span class="sy0">@</span>Verify <span class="sy0">=</span> <span class="st0">'N'</span><span class="sy0">,</span>
<span class="sy0">@</span>CheckSum <span class="sy0">=</span> <span class="st0">'Y'</span><span class="sy0">,</span>
<span class="sy0">@</span>LogToTable <span class="sy0">=</span> <span class="st0">'Y'</span><span class="sy0">,</span>
<span class="sy0">@</span>Compress <span class="sy0">=</span> <span class="st0">'Y'</span><span class="sy0">,</span>
<span class="sy0">@</span>CopyOnly <span class="sy0">=</span> <span class="st0">'Y'</span></pre></div></div>
<p>Then restore onto the other Managed Instance:</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="powershell" style="font-family:monospace;">RESTORE DATABASE <span class="br0">[</span>MyDB<span class="br0">]</span> FROM URL <span class="sy0">=</span> N<span class="st0">'https://mystorageaccount.blob.core.windows.net/mycontainer/MyDB.bak'</span></pre></div></div>
<p>Yeah, a bit cumbersome, but it works and runs, and solves the client’s problem.</p>



<h3 class="wp-block-heading">Which?</h3>



<p>As in all things SQL, it depends. For our client, the simple backup and restore was the solution. They were OK with data being up to 24 hours old for their reporting in this scenario.</p>



<p>If using the PowerShell cmdlets, the target database is unavailable for connections until you issue the Complete cmdlet. But it lets you copy multiple databases, not just one.</p>



<p>It really just comes down to what you are attempting to do. Honestly, for the customer, we could have easily used the PowerShell cmdlets to copy the database each night (deleting the database on the target Managed Instance before starting the copy) and that would eliminate the need to delete the file from blob storage.</p>



<p>So if you looking for ways of copying databases across SQL Managed Instances, you have several options.</p>



<p>&nbsp;</p>
<p>The post <a href="https://sqlsolutionsgroup.com/copying-databases-across-sql-managed-instances/">Copying Databases Across SQL Managed Instances</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/copying-databases-across-sql-managed-instances/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Antipatterns: Common Mistakes with SQL Code</title>
		<link>https://sqlsolutionsgroup.com/common-mistakes-with-sql-code/</link>
					<comments>https://sqlsolutionsgroup.com/common-mistakes-with-sql-code/#comments</comments>
		
		<dc:creator><![CDATA[Rich Benner]]></dc:creator>
		<pubDate>Wed, 21 Feb 2024 08:53:14 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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[Christmas]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">https://sqlsolutionsgroup.com/?p=7015</guid>

					<description><![CDATA[<p>In today’s tech-saturated world, we expect developers to have a broad range of skills and programming languages at their disposal, SQL usually being one of those. This ensures the whole team can help and support one another in their daily lives, but it also leads to mistakes with SQL code. One potential issue here is [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/common-mistakes-with-sql-code/">SQL Server Antipatterns: Common Mistakes with SQL Code</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In today’s tech-saturated world, we expect developers to have a broad range of skills and programming languages at their disposal, SQL usually being one of those. This ensures the whole team can help and support one another in their daily lives, but it also leads to mistakes with SQL code.</p>
<p>One potential issue here is the lack of time to delve really deeply into each programming language at one’s disposal. The thing about SQL Server is that it is a language that performs very differently than, say, C#. Those languages are row based, which means it&#8217;s common to iterate through a data set and process each row individually. This works quite well in those languages, but quite terribly in SQL Server. Being a set-based language, SQL Server prefers to deal with the whole data set at once.</p>
<p>Because of these nuances, it&#8217;s easy for developers to make mistakes when creating SQL server code. Let’s go through some common errors that we see.</p>
<h3><strong>T-SQL</strong></h3>
<p>Let’s start with basic T-SQL code that we commonly see, which are either not great for performance or have other considerations that are often overlooked.</p>
<h4><strong>Select *</strong></h4>
<p>You&#8217;re probably not surprised that we see this a lot. This is often used because the person writing the code isn’t sure exactly what they’ll need to return from the object they’re querying. Using Select * is not a great idea for a several reasons. Here are things to consider:</p>
<ul>
<li>Do you really need all of the data returned? Supporting indexes for queries like this are likely to be wider than necessary in order to cover all of the columns in the table. Wouldn’t it be nice if your indexes were smaller? They’d take less disk space but more importantly would require less I/O to retrieve and occupy less space in memory.</li>
<li>Do you need to return that nvarchar(max) field that you’re got in your table? Not sure if you’ve got one?</li>
<li>What if the underlying structure changes and somebody adds in a (max) field? Do they have to check with you first or will your query suddenly tank and cause you and your users a headache? Wouldn’t happen if we were selecting what is strictly necessary for our query.</li>
</ul>
<p>One of the valid uses of SELECT * is when using something like WHERE EXISTS, where you don’t actually need to return any of the data in the query, something like this:</p>
<p><img decoding="async" width="455" height="88" class="wp-image-7016" src="https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-1.png" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-1.png 455w, https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-1-300x58.png 300w" sizes="(max-width: 455px) 100vw, 455px" /></p>
<p>You could even replace that with a SELECT 1 to be more explicit what you’re doing. This is very much personal preference though.</p>
<h4><strong>Select Into</strong></h4>
<p>Using SELECT..INTO seems like a really easy way of creating tables (whether temporary or permanent), as it takes out a lot of the leg work in defining the structure. An obvious issue here is that your object is created with no constraints (should it be a unique primary key?) and no indexes (do you really want this object to be a heap table?). It also makes troubleshooting more difficult, as if you have something like a truncation issue then you can’t easily see the definition of your object without creating it and going to look for it (do you really want to have to run this code before you can complete the code review?).</p>
<p>Overall, it’s much more controlled if you spend the small amount of time required to declare your object explicitly. You can then make sure it’s exactly what you need and it’s much easier to maintain for those that follow.</p>
<h4><strong>Implicit Conversions</strong></h4>
<p>We often come across implicit conversions when analysing a server’s most poorly performing queries. This happens when you are comparing two pieces of data that are not the same data type. This could be comparing a column to a variable, or it could equally be joining two tables together. If these fields are not the exact same data type, then SQL Server is going to have to perform an implicit convert and convert one to match the other.</p>
<p>This can cause a couple of separate issues:</p>
<ol>
<li>If the server has to convert a column in a table to a different data type then it is not going to be able to use any statistics on the table. These statistics are used when creating the execution plan and will inform how the query is actually run. Without these stats SQL Server can easily make a bad estimate and cause the execution of this query to run very poorly.</li>
<li>The other reason that this will be slow is that SQL Server will have to scan one of the tables in its entirety and convert this field before it can even consider joining the tables together. The larger the underlying tables get, the worse performance becomes.</li>
</ol>
<p>The best way to avoid this issue is to ensure that your data types match. Whether that be making sure your variables match the field or if you are joining two tables on a certain field then making sure that the data types match. Also, remember, varchar(10) is <strong>not</strong> the same as nvarchar(10); they need to be the <strong>exact</strong> same data type.</p>
<h3><strong>Obfuscation</strong></h3>
<p>One of the most common issues we see is code obfuscation. What we mean by this is abstracting some code out of what we’re doing and storing it elsewhere. Doing this makes sense to a certain extent. Why write the same code more than once? If we’re going to use it more than once, why not create an object that we can use everywhere to do this? While this sounds like an excellent idea, let’s discuss why it might not be as great as it first appears</p>
<h4><strong>Nested Objects</strong></h4>
<h4><strong>Views</strong></h4>
<p>We see so many times that people will write a view to perform some logic and then use it everywhere. Simple right? Well, this grows over time. It may be that this is fine for now, but for a certain subset of queries you want to tweak that a little, so a view is created over the top of this view. This can very easily snowball and then you have views relying on views &#8230; relying on views &#8230; relying on views (you get the idea).</p>
<p>Primary issues:</p>
<ol>
<li>Changing logic can be fraught with danger. What if we have to tweak one of these nested views? Do we have the ability to test every single place where this view is used? Do we even know everywhere it’s used?</li>
<li>Troubleshooting can be an absolute nightmare. You’ve got some incorrect data in the final query, but which of the sub views is it coming from? It makes a spider’s web of dependencies that are very time consuming and difficult to track. How much time can you invest in resolving this?</li>
<li>When creating execution plans, SQL Server will only spend so much time investigating these sub views before simply giving up and just running the query however it guesses with no available data. Any ideas how well that’s going to go and how our query is going to perform? Not well.</li>
</ol>
<p>While views make a lot of sense <strong>when used properly</strong>, being aware of the nested views issue is something that could save you some major headaches in the future.</p>
<h4><strong>Scalar Functions</strong></h4>
<p>We see so many functions being used in the wild. Some work well, some not so much. By far the largest problem we come across is the (miss)use of scalar functions. Using a function is extremely common in other languages and they work very well. But there are a couple of very large &#8220;gotchas&#8221; in SQL Server:</p>
<ol>
<li>As soon as you use a scalar function in SQL Server, it forces the transaction to run serially. This means you’re removing any ability for the query to run in parallel, and it therefore will likely dramatically impact the performance of your query. There are some advances here in SQL Server 2022 with <a href="https://learn.microsoft.com/en-us/sql/relational-databases/user-defined-functions/scalar-udf-inlining">Scalar UDF Inlining</a>, but this is a relatively new feature and is not available for everybody.</li>
<li>Functions are also effectively treated as separate transactions, once called. You won’t see them in execution plans and this makes them extremely difficult to locate, investigate and troubleshoot. It’s super easy to miss them all together.</li>
<li>Scalar functions are also executed once per row of the data set. Remember how SQL Server is a set-based language and likes dealing with a large data set all at once? Well, scalar functions will pull that particular rug out from under you and turn it into a row-based calculation which will have those very same performance issues.</li>
<li>You also have the recurring issue of knowing exactly what the function is doing. What parameters are being passed? What’s the actual code that the function is executing? These questions can often be tricky to answer.</li>
</ol>
<p>In our experience, scalar functions are fine when used correctly (sparingly and not in set-based operations. Think setting a local variable using a function, but it’s extremely easy to use them incorrectly and shoot yourself in the foot using them.</p>
<h4><strong>IN (Subqueries) </strong></h4>
<p>Something that is very easy to do is to run a query.</p>
<p>Using the Stack Overflow database, let’s say I wanted to see all posts for all users with more than 10,000 reputation points. I could write something like this;</p>
<p><img decoding="async" width="405" height="104" class="wp-image-7017" src="https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-2.png" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-2.png 405w, https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-2-300x77.png 300w" sizes="(max-width: 405px) 100vw, 405px" /></p>
<p>Seems pretty simple, right? Well, the issue here is what goes on behind the scenes. That IN statement gets parsed out to something like this;</p>
<p><img loading="lazy" decoding="async" width="544" height="49" class="wp-image-7018" src="https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-3.png" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-3.png 544w, https://sqlsolutionsgroup.com/wp-content/uploads/2024/02/word-image-7015-3-300x27.png 300w" sizes="(max-width: 544px) 100vw, 544px" /></p>
<p>In the example query here, there would be 25,334 clauses in this statement. That’s a lot of data to parse through and that just won’t scale well within SQL Server. Joins would be the correct way of doing this. Whether a direct join is possible or whether the subquery is better to be separated and the result put into a temp table, that will all depend on the logic of your particular query.</p>
<h4><strong>Triggers</strong></h4>
<p>Aah, triggers, the silent killers. Sometimes necessary, always costly. The amount of times that we’ve seen poorly performing servers and there are triggers firing all over the place is definitely a non-zero number. They have the same issue as scalar functions, in which they are treated as a separate transaction and won’t be found in execution plans and the like.</p>
<p>Sometimes triggers are necessary, but it’s so easy to introduce them unnecessarily and then suffer the performance impact that follows. Need to do something upon or after insert? There are other ways of resolving those requirements without resorting to Triggers.</p>
<h4><strong>Synonyms</strong></h4>
<p>We’re glad that a lot of people don’t even know that <a href="https://sqlsolutionsgroup.com/synonyms-sql-server-good-bad/">synonyms are a thing</a> in SQL Server, but when we do find them they can cause major confusion. While we totally understand that the business will often push for the simplest (cheapest) solution to resolve the issue of object renaming, it’ll definitely cause confusion when troubleshooting and ultimately become a maintenance issue.</p>
<h3><strong>Linked Servers used Incorrectly</strong></h3>
<p>Linked servers can be highly effective <a href="https://sqlsolutionsgroup.com/using-linked-servers-the-right-way/">when used correctly</a>. The issues that occur are with understanding how linked servers execute queries locally and remotely. If we just include a linked server using four part naming convention ([RemoteServerName].[Database].[Schema].[Object]), then our local server retrieves all data from the remote server and processes data locally. This may be fine if we’re doing a simple query, where we’re selecting all data in a single table. But once we get to adding in filtering and/or manipulating the data in any way (joining for example), then this can get inefficient very quickly.</p>
<p>There has been some change in recent versions of SQL Server on how it deals with these types of connections. Ultimately the better way of processing this data is to either push your results from the remote server and then deal with these results, or to use OPENROWSET. This avoids the issues above and represents best practice for querying linked servers.</p>
<h3><strong>Many Database Problem</strong></h3>
<p>For companies who are vendors or provide a service to multiple clients, it is not unusual to see a database created for each customer. The thinking here is that it silos each customer’s data into a separate database to ensure there is no risk of data being accessed by the wrong user. This makes sense, right? Sure, but there are definitely some issues that can arise from this:</p>
<ol>
<li>Standardisation is a big one. Can you guarantee that your databases are identical to each other? Are they even meant to be? If not, you will have issues performing operations that have to update all databases. Do you need to push a maintenance patch or hotfix? What if some databases have incompatible schemas? You’re going to run into a big headache here really quick.</li>
<li>Context switching is absolutely an issue you should be considering in this scenario. Because the engine has to switch between databases constantly, it can put a hidden workload onto the server and cause some big issues if not monitored very closely.</li>
<li>Maintenance is also another thing to consider. Many databases will require many backups, will contain many indexes, and statistics that require maintenance (<strong>you’re doing this, right?</strong>). Everything becomes a list that needs sorting through before any potential issues can be resolved.</li>
</ol>
<p>The two main options we have here are to consolidate your customers into fewer databases (we’re aware of how much work this can be to implement) or to simply split your server into smaller servers and host fewer customers on each. In today’s world of virtualisation, this is a lot simpler than it used to be. You just need to monitor them to ensure you don’t have all of your most busy customers on the same server.</p>
<p><strong>Many Tenants on a Host</strong></p>
<p>This one is tricky without having access to the virtualisation layer. We have absolutely seen issues with over provisioning hardware between multiple tenants. It seems obvious that you should consider doing this. Each server is not going to be using 100% of the resources allocated to it, so why not allow them all to have a bit more so you can utilise your hardware?</p>
<p>Let’s say we have 20 CPU cores and 1TB of ram on a server and we have 10 tenants on this host. If we were hard provisioning, we would allocate two CPU cores and 100GB of ram to each of these tenants. That way, everybody always has everything they want. But then we notice that the resources are not often used — we sit around with spare CPU going idle. Why not put a few more servers on this box so we can save money? Makes sense, right? The directors would love if we can provide a cost saving.</p>
<p>The issue comes when you have your busy periods, whether that be the holidays, or whether that’s Monday mornings when your customers come online. What then? Well, the tenants are going to fight for those resources. Your servers are going to think they each have two cores and can use them. But because we’ve now got 20 tenants on this host, they can not necessarily have that many resources at any time.</p>
<p>Seeing this inside SQL Server is extremely difficult and even experienced troubleshooters would find it hard to find that this was the problem.</p>
<p>A similar issue is that of &#8220;noisy neighbours&#8221;. What if one particular tenant on the host uses most of the resources? There’s not much the other tenants can do about it. They’re going to struggle to do what they need to and there’s nothing they can do about it.</p>
<h3><strong>Keeping Connections Open</strong></h3>
<p>When connecting to SQL Server, you’ll likely do multiple things, so it makes sense to keep the connection open until you finish the entire workload, right? That can come with some very expensive lessons to learn if this becomes commonplace in your environment.</p>
<p>There are a total of <a href="https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-the-user-connections-server-configuration-option">32,767 user connections</a> available in SQL Server. What happens when these are all used up? You simply cannot make new connections to the server. I will leave the consequences of that to your own imagination.</p>
<p>It’s very much best practice to only keep a connection open for as long as you absolutely require it. The resources required to open a new connection are negligible, true. But the long term consequences of keeping them open can be drastic. It’s also worth noting that you may not have an issue with this right now, but as databases and user counts grow, do you want to risk this or get it right from the beginning?</p>
<h3><strong>Debug Mode</strong></h3>
<p>It’s rare that a company will add the option to be able to debug SQL code. You may have the error message that something’s throwing, but where specifically is that error coming from? Most of the time somebody will need to extract the T-SQL code piece by piece and run it until you get to the problem code. This can be extremely time consuming and is luckily something that is absolutely avoidable.</p>
<p>By adding a @debug variable and the related code, it will save you so much time. The idea of @debug is that when you enable the flag, it will log relevant information into a logging table so you can analyse it separately.</p>
<p>Adding the variable and related logging isn’t free. It’ll take a little time to ensure it works, but by getting to the standard where code has a debug option, you will make the long-term viability and maintenance so much easier.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/common-mistakes-with-sql-code/">SQL Server Antipatterns: Common Mistakes with SQL Code</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/common-mistakes-with-sql-code/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>The Right Tool for the Right Job</title>
		<link>https://sqlsolutionsgroup.com/the-right-tool-for-the-right-job/</link>
					<comments>https://sqlsolutionsgroup.com/the-right-tool-for-the-right-job/#comments</comments>
		
		<dc:creator><![CDATA[Scott Klein]]></dc:creator>
		<pubDate>Mon, 15 Jan 2024 12:42:03 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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[Christmas]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">https://sqlsolutionsgroup.com/?p=7000</guid>

					<description><![CDATA[<p>I’m looking forward to 2024. From many perspectives, I think we are going to see great advancements, including in technology, that on one hand will make our lives easier, but also make our decisions a bit harder.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/the-right-tool-for-the-right-job/">The Right Tool for the Right Job</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><em><strong>Reminiscing</strong></em></p>
<p>We’re two weeks into 2024 and I’m sitting here staring at my carousel M&amp;M dispenser (it used to be full) of dark chocolate peanut M&amp;Ms. Some people collect hats, stamps, or Lego sets. I collect M&amp;M dispensers. I probably have 50 of them (and the dark chocolate peanut M&amp;M is the ONLY way to go, btw), and I&#8217;m wondering what 2024 will bring.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-7001" src="https://sqlsolutionsgroup.com/wp-content/uploads/2024/01/a-toy-machine-and-a-microphone-on-a-table-descrip.png" alt="A toy machine and a microphone on a table

Description automatically generated" width="650" height="405" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2024/01/a-toy-machine-and-a-microphone-on-a-table-descrip.png 1201w, https://sqlsolutionsgroup.com/wp-content/uploads/2024/01/a-toy-machine-and-a-microphone-on-a-table-descrip-300x187.png 300w, https://sqlsolutionsgroup.com/wp-content/uploads/2024/01/a-toy-machine-and-a-microphone-on-a-table-descrip-1024x638.png 1024w, https://sqlsolutionsgroup.com/wp-content/uploads/2024/01/a-toy-machine-and-a-microphone-on-a-table-descrip-768x478.png 768w" sizes="(max-width: 650px) 100vw, 650px" /></p>
<p>And yes, that is a mic propped up on a mini Starbucks cup because my laptop mic sounds like crap. So I hooked that thing up, but it lacks a stand, so I’ll be ordering one of those.</p>
<p>Anyway, back to 2024.</p>
<p>I don’t want to turn this blog into a “look back at 2023” or “what could have been” post. I want to look forward. I mean, it’s 2024 and, barely two weeks in, a lot has happened. Microsoft has already released CU 11 for SQL Server 2022. Pete Carroll and Bill Belichick (two GREAT NFL coaches) were let go, and Nick Saban retired (a phenomenal college coach), all in the span of 24 hours.</p>
<p>Plus, for the past few days my laptop has been popping up messages that my Norton antivirus software has expired (and others), and I am not even running it. Looks like I’ll be paving my laptop this weekend. Ugh, welcome to 2024.</p>
<p>But honestly, I’m looking forward to 2024. From many perspectives, I think we are going to see great advancements, including in technology, that on one hand will make our lives easier, but also make our decisions a bit harder. My dad died last July, a week before his 90th birthday, and for the few months following, my bothers and I helped Mom clean and organize a lot of my dad’s things.</p>
<p>He had a lot of tools. <em><strong>A lot.</strong></em> It took us days just to go through his tools. I brought some back home with me. My dad had a really nice snow blower, because where he lived it snowed quite a bit, and he used it to clear the pathways of not only his house, but his neighbors&#8217;. He enjoyed bundling up and firing up his trusty mega snowblower 9000 (no, it’s not really called that), making mounds and piles of snow by clearing the sidewalks and walkways of his neighbors.</p>
<p>Where I live, it doesn’t snow that much, so I’m torn. I’d love for it to snow enough to justify firing up the snow blower, but I also DON’T want it to snow that much. When it does snow (like it did the other night), I’m looking at my inherited snow blower and snow shovels and wondering what the best tool for the job would be. My neighbors would probably get a kick out of seeing me fire that thing up for only a 1/8 of an inch of snow, which, if I just waited a couple of hours, would be gone anyway. *Sigh*</p>
<p>So, here I sit, two weeks into 2024, pushing the button on my carousel M&amp;M dispenser waiting for it to drop out those precious dark chocolate peanut M&amp;M’s, thinking about the upcoming projects and the technology available to me.</p>
<p>Do I use SSIS or Azure Data Factory? Would a particular client benefit from a distributed availability group? Why isn’t Query Store enabled at this other client? What about AI (have you seen the movies <em>M3GAN</em> and <em>Moonfall?</em>. Um, no.) I’m kidding a bit, because I just read a great blog post by Daniel Janik on <a href="https://sqltechblog.com/2024/01/08/using-ai-to-create-test-data/">how to use AI to generate test data</a> in SQL Server.</p>
<p>Anyway, make 2024 a great one. Help others, be kind, play with awesome technology, and eat a bunch of dark chocolate peanut M&amp;Ms (preferably out of a carousel dispenser).</p>
<p>The post <a href="https://sqlsolutionsgroup.com/the-right-tool-for-the-right-job/">The Right Tool for the Right Job</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/the-right-tool-for-the-right-job/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>A Visit from St. Randy: &#8216;Twas the night in the server room, silent and cold &#8230;</title>
		<link>https://sqlsolutionsgroup.com/a-visit-from-st-randy-twas-the-night-in-the-server-room-silent-and-cold/</link>
					<comments>https://sqlsolutionsgroup.com/a-visit-from-st-randy-twas-the-night-in-the-server-room-silent-and-cold/#respond</comments>
		
		<dc:creator><![CDATA[Jason Russell]]></dc:creator>
		<pubDate>Thu, 21 Dec 2023 15:56:28 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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[Christmas]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">https://sqlsolutionsgroup.com/?p=6994</guid>

					<description><![CDATA[<p>Continuing an SSG tradition of adapting "A Visit from St. Nicholas," the classic poem by Clement Clarke Moore. Happy holidays to all!</p>
<p>The post <a href="https://sqlsolutionsgroup.com/a-visit-from-st-randy-twas-the-night-in-the-server-room-silent-and-cold/">A Visit from St. Randy: &#8216;Twas the night in the server room, silent and cold &#8230;</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&#8216;Twas the night in the server room, silent and cold,<br />
No backups were stirring, a sight to behold.<br />
The DBA sat, weary and aware,<br />
In hopes that his databases soon would repair.</p>
<p>When out in the log files, there arose such a clatter,<br />
I sprang from my desk to see what was the matter.<br />
Away to the console, I flew like a flash,<br />
Entered some commands, my heart in the trash.</p>
<p>The server lights flickered, a troubling sign,<br />
In the midst of the chaos, the disk space declined.<br />
When, what to my wondering ear should I hear,<br />
A reassuring voice that allayed my fear.</p>
<p>“<em><strong>Now deadlock! Now timeout! Now, replication delay!</strong></em><br />
<em><strong> On, fragmentation! On, failed backup today!</strong></em><br />
<em><strong> To the top of the stack! To the cause of the stall!</strong></em><br />
<em><strong> Now dash away, dash away, dash away all!</strong></em>&#8221;</p>
<p>And then, in a twinkling, I heard on the drive,<br />
The whirring and clicking, as if barely alive.<br />
As I scratched my head, and was turning around,<br />
Down the Ethernet cable, St. Randy came with a bound.</p>
<p>He was dressed all in code, from his head to his foot,<br />
And his clothes were all tarnished with bytes and soot.<br />
A bundle of patches he had flung on his back,<br />
And he looked like a troubleshooter, just opening his pack.</p>
<p>He was cheerful and spry, a jolly old DBA,<br />
And I laughed when I saw him, in spite of the fray.<br />
A wink of his eye and a nod of his head,<br />
Soon gave me to know I had nothing to dread.</p>
<p>He spoke not a word, but went straight to his work,<br />
And fixed all the queries, then turned with a jerk.<br />
And laying a finger aside of his nose,<br />
With a nod, up the Ethernet cable he rose.</p>
<p>He sprang to his sleigh, to his team gave a shout,<br />
And away they all flew, like a backup job, no doubt.<br />
But I heard him exclaim, as he drove out of sight,<br />
&#8220;<em><strong>Happy SQL to all, and to all a good night!</strong></em>&#8220;<span class="c-message__edited_label" dir="ltr" data-sk="tooltip_parent"> </span></p>
<p>The post <a href="https://sqlsolutionsgroup.com/a-visit-from-st-randy-twas-the-night-in-the-server-room-silent-and-cold/">A Visit from St. Randy: &#8216;Twas the night in the server room, silent and cold &#8230;</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/a-visit-from-st-randy-twas-the-night-in-the-server-room-silent-and-cold/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server on a Diet: Improve the health of your database</title>
		<link>https://sqlsolutionsgroup.com/improve_health_of_database/</link>
					<comments>https://sqlsolutionsgroup.com/improve_health_of_database/#respond</comments>
		
		<dc:creator><![CDATA[Rich Benner]]></dc:creator>
		<pubDate>Thu, 14 Dec 2023 11:59:13 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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">https://sqlsolutionsgroup.com/?p=6991</guid>

					<description><![CDATA[<p>We often see databases that are simply larger than they need to be. This is usually attributable to technical debt and the gradual growth of data over time. So, what does it look like to put SQL Server on a diet and improve the health of your database? The good news is that this data [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/improve_health_of_database/">SQL Server on a Diet: Improve the health of your database</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We often see databases that are simply larger than they need to be. This is usually attributable to technical debt and the gradual growth of data over time. So, what does it look like to put SQL Server on a diet and improve the health of your database?</p>
<p>The good news is that this data isn’t often needed at all or is only needed very infrequently. Therefore, we can use a few approaches to make your database simply perform better <strong>and</strong> utilize fewer resources. Wouldn’t it be nice if your queries ran faster and processes like your backups had to do less work because your database is just smaller?</p>
<p>We can get there! In this post, we’ll look at a few different things you can implement in order to improve your database’s health.</p>
<h3><strong>Unused and Redundant Data</strong></h3>
<p>The first and most obvious way to slim down your database is to find unused data and simply delete it from the database if it’s not needed any more. Do you have a table where you have a large amount of data that’s old and just not used? Is there a reason that we’re keeping it around?</p>
<p>There are some obvious blockers to this. Perhaps you deal with data that you have to keep for a certain amount of time due to regulatory reasons (financial, medical, etc.). If that’s your scenario, you’ll want to look at some of the other options on this list.</p>
<p>Do remember, though, that the requirement to store data does not necessarily mean that it needs to be attached to a live server and accessible at all times. In some cases, backing up your database and storing the backup is completely acceptable to meet the requirement. Considering how cheap blob storage is nowadays, this could be a very cost-effective way of being compliant with data retention rules.</p>
<h3><strong>Archive Tables</strong></h3>
<p>Is the case above true but sometimes you do need to query the historical data? You could consider an archive table. These are usually the same table name followed by _Archive or _History and used for storing data that still needs to be “queryable” but not used for most queries.</p>
<p>This will require code changes if you’re accessing the data via an application. If you require the older data then you’ll need a UNION ALL to join the two tables together. You’ll also want to watch out for any schema changes to either database as you’ll want to keep them the same for performance reasons.</p>
<p>The advantage of this approach is that your most commonly executed queries that deal with the latest data simply have less work to do. You have less data to read from disk, less data to store in memory, and less data to join to other data.</p>
<p>Another trick you could apply is to use different filegroups for the archive tables. When you do that, you can put the archive data on a drive that isn’t your nice, expensive, fast disks. It’ll be slower to retrieve, but with this data, does that matter?</p>
<h3><strong>Partitioning</strong></h3>
<p>If you don’t want to delete this data or move it to another table, then you could consider partitioning your tables. This process can be tricky to get right so definitely research this option, but when it does work well it can be an excellent solution.</p>
<p>Partitioning is the process of separating your data into segments between given values with the idea being that you only query the range that contains the data you need. Dates are often used for this. For example, people might partition the last years’ worth of data by month (so 12 partitions), and then have anything older than that sit in a large partition dedicated to historical data. This allows for queries that query this month’s data to just deal with a small fraction of the data in the table, which is great for performance.</p>
<p>Important to note: There is usually maintenance required on this, however. You probably don’t want to make 100&lt; partitions if you were going with monthly data — in other words, having a partition for each month from the start of time, for this table, and allowing for the next 10 or 20 years.</p>
<p>The better approach is to have a monthly SQL Agent job that deletes your oldest partition (and moves the data into the ‘historical’ partition) and then makes a new one for the next month. This also applies if you’re partitioning based upon a surrogate key (e.g. splitting it into ranges of a certain number of IDs).</p>
<p>The advantage of partitioning is that if your queries always search on a field that uses the partitioning key then you don’t need to make any code changes in the app to take advantage of this feature!</p>
<h3><strong>Filtered indexes</strong></h3>
<p>Being able to use filtered indexes is a godsend when it comes to dealing with certain types of data. One example we see a lot is the use of soft deletes where a table contains a column called IsActive or IsDeleted (or similar) and a bit field used for this data. Often when queries are written against these tables, they’ll always search for IsActive = 1 or IsDeleted = 0 so they’re only looking at live data. This makes them an ideal target for filtered indexes.</p>
<p>Filtered indexes act exactly like a normal non clustered index but with the addition of a filter. It will look something like this:</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="kw1">CREATE</span> <span class="kw1">INDEX</span> IX_IndexName
<span class="kw1">ON</span> TableName <span class="br0">&#40;</span>TableIDField, IsActive<span class="br0">&#41;</span>
<span class="kw1">WHERE</span> IsActive <span class="sy0">=</span> <span class="nu0">1</span></pre></div></div></p>
<p>&nbsp;</p>
<p>It’s important to realize that you want the filtered column in the indexed fields for best performance and to ensure the optimizer chooses to use this index.</p>
<h3><strong>Reduced Index Width</strong></h3>
<p>Another issue that we see more than we’d like is the use of very wide indexes. Every field in your index costs extra storage space and increases your memory requirements. It’s very easy to find a list of indexes that have a large amount of columns. Just use a query like this:</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="kw1">SELECT</span> 
     t.<span class="me1">name</span> TableName,
     i.<span class="me1">name</span> IndexName,
     i.<span class="me1">index_id</span> IndexID,
     <span class="kw2">COUNT</span><span class="br0">&#40;</span>col.<span class="me1">name</span><span class="br0">&#41;</span> ColumnCount
<span class="kw1">FROM</span> sys.<span class="me1">indexes</span> i 
<span class="kw1">INNER</span> <span class="sy0">JOIN</span> sys.<span class="me1">index_columns</span> ic <span class="kw1">ON</span>  i.<span class="kw2">OBJECT_ID</span> <span class="sy0">=</span> ic.<span class="kw2">OBJECT_ID</span> and i.<span class="me1">index_id</span> <span class="sy0">=</span> ic.<span class="me1">index_id</span> 
<span class="kw1">INNER</span> <span class="sy0">JOIN</span> sys.<span class="me1">columns</span> col <span class="kw1">ON</span> ic.<span class="kw2">OBJECT_ID</span> <span class="sy0">=</span> col.<span class="kw2">OBJECT_ID</span> and ic.<span class="me1">column_id</span> <span class="sy0">=</span> col.<span class="me1">column_id</span> 
<span class="kw1">INNER</span> <span class="sy0">JOIN</span> sys.<span class="me1">tables</span> t <span class="kw1">ON</span> i.<span class="kw2">OBJECT_ID</span> <span class="sy0">=</span> t.<span class="kw2">OBJECT_ID</span> 
<span class="kw1">WHERE</span> i.<span class="me1">is_primary_key</span> <span class="sy0">=</span> 0 
	<span class="sy0">AND</span> i.<span class="me1">is_unique_constraint</span> <span class="sy0">=</span> 0 
	<span class="sy0">AND</span> t.<span class="me1">is_ms_shipped</span> <span class="sy0">=</span> 0 
<span class="kw1">GROUP</span> <span class="kw1">BY</span> t.<span class="me1">name</span>, i.<span class="me1">name</span>, i.<span class="me1">index_id</span>
<span class="kw1">ORDER</span> <span class="kw1">BY</span> <span class="kw2">COUNT</span><span class="br0">&#40;</span>col.<span class="me1">name</span><span class="br0">&#41;</span> <span class="kw1">DESC</span></pre></div></div></p>
<p>&nbsp;</p>
<p>That will return a list of all of your indexes and the number of columns they include, sorted descending by column count. You’ll then have to look at these indexes, look at the queries that hit these tables (query store can be excellent for that) and decide if you can reduce the number of columns. The biggest wins will be the largest data types so look out for things like (max) fields and ntext.</p>
<h3><strong>Fragmentation</strong></h3>
<p>If you don’t have index maintenance scheduled, you could well have some very fragmented tables. This is caused by data deletions and updates, which can happen a lot on heap tables too. It’s easy to check out your fragmentation using a query like the one below:</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="kw1">SELECT</span> 
	T.<span class="me1">name</span> TableName,
	I.<span class="me1">name</span> IndexName,
	ps.<span class="me1">avg_fragmentation_in_percent</span>,
	ps.<span class="me1">page_count</span>
<span class="kw1">FROM</span> sys.<span class="me1">dm_db_index_physical_stats</span> <span class="br0">&#40;</span><span class="kw2">DB_ID</span><span class="br0">&#40;</span><span class="br0">&#41;</span>, <span class="sy0">NULL</span>, <span class="sy0">NULL</span>, <span class="sy0">NULL</span>, <span class="sy0">NULL</span><span class="br0">&#41;</span> <span class="kw1">AS</span> ps
<span class="kw1">INNER</span> <span class="sy0">JOIN</span> sys.<span class="me1">tables</span> t <span class="kw1">ON</span> ps.<span class="kw2">OBJECT_ID</span> <span class="sy0">=</span> t.<span class="kw2">OBJECT_ID</span> 
<span class="kw1">INNER</span> <span class="sy0">JOIN</span> sys.<span class="me1">schemas</span> s <span class="kw1">ON</span> t.<span class="me1">schema_id</span> <span class="sy0">=</span> s.<span class="me1">schema_id</span>
<span class="kw1">INNER</span> <span class="sy0">JOIN</span> sys.<span class="me1">indexes</span> i <span class="kw1">ON</span> i.<span class="kw2">OBJECT_ID</span> <span class="sy0">=</span> ps.<span class="kw2">OBJECT_ID</span> <span class="sy0">AND</span> ps.<span class="me1">index_id</span> <span class="sy0">=</span> i.<span class="me1">index_id</span>
<span class="kw1">WHERE</span> I.<span class="me1">name</span> <span class="kw1">IS</span> not null
	<span class="sy0">AND</span> ps.<span class="me1">avg_fragmentation_in_percent</span> <span class="sy0">&gt;</span> 0
	<span class="sy0">AND</span> ps.<span class="me1">page_count</span> <span class="sy0">&gt;</span> 1000
<span class="kw1">ORDER</span> <span class="kw1">BY</span> ps.<span class="me1">avg_fragmentation_in_percent</span> <span class="kw1">DESC</span></pre></div></div></p>
<p>&nbsp;</p>
<p>This query returns all fragmented indexes, as long as they’re over 1000 data pages (8MB) in size. If you have some large and fragmented indexes, then you’ll want to do some reorganizing or rebuilding. You’ll then want to set up regular maintenance. To do this, we recommend using <a href="https://ola.hallengren.com/">Ola Hallengren’s</a> index maintenance solution.</p>
<h3><strong>Compression</strong></h3>
<p>There are some excellent options for compressing your data — depending on what your data is exactly, because some data is more compressible than others.</p>
<p>Row and page compression can be an effective way to reduce the size of your tables. There are some considerations here, including SQL Server editions (e.g. all versions of SQL Server 2022 support data compression, but if you’re on 2016 then you need to be on Service Pack 1 or later).</p>
<p>Columnstore compression is a completely different way to store and compress data. As the name would suggest, this doesn’t compress data row by row. Rather, it compresses columns worth of data. This is excellent if you have a lot of duplicated data within columns of your table. This is particularly useful in data warehouse solutions. The downside with columnstore is that in an OLTP workload environment, any inserts into or updates to this table will have to do more work due to the compression. This very much depends on the data and your workloads.</p>
<h3><strong>Conclusion</strong></h3>
<p>This is not an exhaustive list of all the options, but you should now have a great start and some ideas of what you can do in your own environment. Smaller data is faster data, after all, so let’s try and get your database running like greased lightning. If you’re reading before it happens, you can also <a href="https://sqlsolutionsgroup.com/events/sql-server-on-a-diet/">join me for a webinar on this topic</a> scheduled for Wed., Jan. 24, 2024. We’ll cover many of the same topics — just more in depth and with demos and additional useful insights.</p>
<p>If you want a hand with any of this, then please get in touch and we’d be more than willing to help.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/improve_health_of_database/">SQL Server on a Diet: Improve the health of your database</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/improve_health_of_database/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Health Considerations in the Data Management Space</title>
		<link>https://sqlsolutionsgroup.com/health-considerations/</link>
					<comments>https://sqlsolutionsgroup.com/health-considerations/#respond</comments>
		
		<dc:creator><![CDATA[Jason Russell]]></dc:creator>
		<pubDate>Wed, 15 Nov 2023 00:17:41 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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">https://sqlsolutionsgroup.com/?p=6969</guid>

					<description><![CDATA[<p>If your health is suffering, you're not as much of an asset to your employer, so it's in their and your best interests to ensure as much "balance" as possible.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/health-considerations/">Health Considerations in the Data Management Space</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In the data management space, or indeed just about every aspect of human endeavor, health is an important consideration. </p>



<p>And I don&#8217;t mean the health of your data, your queries, your hardware, or anything like that. I&#8217;m talking about the health of the most critical machine, your body. </p>



<p>Steve Jones recently published an article on SQL Server Central encouraging readers to &#8220;<a href="https://www.sqlservercentral.com/editorials/dont-always-be-a-hero">don&#8217;t (always) be a hero</a>.&#8221; Steve relates an experience early in his career when he was supporting an installation of SQL Server 4.2 on OS/2 1.2&nbsp;on New Year&#8217;s Eve. Just as he was prepping to leave 30 minutes into the new year, the install locked up.   </p>



<p>In short, Steve didn&#8217;t leave until early on Jan. 2nd. &#8220;I was a hero that January, as were my co-workers, with all of us logging around 100 hours each week that month,&#8221; Steve reports. </p>



<p>You&#8217;ve probably been there once or twice &#8230; or two or three dozen times. Something hits the fan and the idea of &#8220;9 to 5&#8221; and any personal plans go out the window for the foreseeable future. To be sure, anyone in this space who is expecting 9 to 5 probably needs to see a therapist, but working 60 hours a week or more should be rare, not normal.</p>



<p>Steve&#8217;s point is:</p>



<p><blockquote>We need to be heroes at times, but those ought to be emergencies, and they ought to be rare. Most IT professionals (and others) I know will work longer or harder when needed, but the need can&#8217;t be constant or even regular. It should be an unusual situation. If it&#8217;s not, then something has to change, at least for me.</blockquote>



<p>Most jobs involve some stress, and that&#8217;s almost unavoidable. The problem is when the stress is constant. Chronic stress is recognized as <a href="https://pubmed.ncbi.nlm.nih.gov/32210441/">a risk factor</a> for mental diseases and disease states, including cardiovascular disease.</p>



<p>Heart rate variability, or HRV, is a useful measure for stress. <a href="https://www.firstbeat.com/en/blog/what-is-heart-rate-variability-hrv/">High variability is specifically associated</a> low stress, leading to reduced mortality and improved well-being and quality of life. If that sentence wasn&#8217;t worded how you expected, think of low variability as always being in a &#8220;fight or flight&#8221; mode. Your heart is constantly racing, so the heartrate remains high &#8230; and variability is low. </p>



<p>So now the good news. Wearable devices, including Apple Watches, can help you track HRV. Equipped with this knowledge, you can work on (or at least try to work on) relieving your stress. Meditation, short walks, breathing exercises, visualization &#8230; these and other techniques can all help. </p>



<p>Quality sleep is another key part of maintaining your health. More good news: the <em>Wall Street Journal </em><a href="https://www.wsj.com/health/wellness/sleep-science-longevity-0f35a573">recently reported</a> on a study that showed getting less than eight hours of sleep is not as bad as previously thought: </p>



<p><blockquote>Sleep “regularity”—going to bed and waking up at consistent times with few mid-slumber interruptions—matters more than how long you sleep. Sleeping six hours every night on a consistent schedule was associated with a lower risk of early death than sleeping eight hours with very irregular habits.</p><p>Sleep duration was still important: People who got long, consistent sleep had the lowest mortality risk, says Angus Burns, a research fellow at Harvard Medical School who co-wrote the study. But shorter, regular sleep was generally associated with lower mortality than longer, inconsistent sleep. </blockquote></p>



<p>Diet is another key consideration. Instead of getting into that, just consider these: Cut back on sugar-laden soda, and instead of chips or other high calorie snacks, try veggies (baby carrots, anyone?) or fruit. It&#8217;s an easy switch that can make a big difference. </p>



<p>If your health is suffering, you&#8217;re not as much of an asset to your employer, so it&#8217;s in their and your best interests to ensure as much &#8220;balance&#8221; as possible. In Steve&#8217;s words, don&#8217;t be a hero. If you&#8217;re struggling and don&#8217;t see any light at the end of the tunnel, speak up. </p>
<p>The post <a href="https://sqlsolutionsgroup.com/health-considerations/">Health Considerations in the Data Management Space</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/health-considerations/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>PolyBase vs Linked Servers </title>
		<link>https://sqlsolutionsgroup.com/polybase-vs-linked-servers/</link>
					<comments>https://sqlsolutionsgroup.com/polybase-vs-linked-servers/#respond</comments>
		
		<dc:creator><![CDATA[Scott Klein]]></dc:creator>
		<pubDate>Thu, 19 Oct 2023 16:15:12 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#parallelism #azure]]></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">https://sqlsolutionsgroup.com/?p=6951</guid>

					<description><![CDATA[<p>PolyBase vs. Linked Servers &#8230; which wins? Recently we have had several clients reach out to us about a data archival solution. Some of their databases are in the TB range, with data going back 7-10 years or even more. Keeping this data in the database is costly due to disk space needs, and query [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/polybase-vs-linked-servers/">PolyBase vs Linked Servers </a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>PolyBase vs. Linked Servers &#8230; which wins? Recently we have had several clients reach out to us about a data archival solution. Some of their databases are in the TB range, with data going back 7-10 years or even more. Keeping this data in the database is costly due to disk space needs, and query performance can be affected due to the amount of data being queried as well as index sizes, etc.</p>
<p>Several of our clients have looked at a range of different solutions, such as copying “old” data to a different report or read-only server and hooking up a Linked Server through which to query the older data when needed. Another option is creating a “history” table in the same database and moving the older data to that table.</p>
<p>In both cases, this doesn’t solve the disk space issue, and it is still a costly storage solution. With the first scenario, I’m sure we have all been a little frustrated at the performance of Linked Servers at one time or another. In all cases, we had a requirements-gathering session with each client to determine several items, including:</p>
<ul>
<li>Does the archive data need to be queried, and if so, how often?</li>
<li>How much data needs to be archived?</li>
<li>Does referential integrity need to be kept between current and archive data?</li>
<li>Is cloud storage an option?</li>
</ul>
<p>There are other questions that we could ask, but these are the most critical because it establishes a baseline and determines the technology we can work with. In some cases, cloud storage is not an option, so we needed to stick with an on-premises solution. Where cloud storage was an option, that opened things up and we were able to look at and utilize some great technologies.</p>
<p>Now, where cloud storage wasn’t an option, there were still some things that we could look at that are strong, viable options, thus the topic of this blog. With SQL Server 2016, Microsoft added the ability to use PolyBase to query other SQL Server instances. This is a game changer, as PolyBase is very powerful. We at SSG set out to determine which is faster and more efficient, PolyBase or Linked Servers, when querying one SQL Server instance from another SQL Server instance.</p>
<p>Honestly, what we found was very surprising. <strong><em>Extremely surprising</em></strong>. Granted, all our tests were performed using SQL Server 2019 and SQL Server 2022, but even then, what we found was quite shocking.</p>
<p>I could walk through everything here, which would make for an extremely long blog, so I did a webinar on this exact topic with a lot of demos, discussion, and insights, and you can view it <a href="https://www.youtube.com/watch?v=l9Rc5nMuq48" target="_blank" rel="noopener">here</a>. Let us know what you think as we always like to hear from you.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/polybase-vs-linked-servers/">PolyBase vs Linked Servers </a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/polybase-vs-linked-servers/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
