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

<channel>
	<title>SQL Server Archives | SQL Solutions Group</title>
	<atom:link href="https://sqlsolutionsgroup.com/tag/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlsolutionsgroup.com/tag/sql-server/</link>
	<description></description>
	<lastBuildDate>Tue, 07 Jul 2026 23:05:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://sqlsolutionsgroup.com/wp-content/uploads/2021/01/cropped-SSG_FAVICON0002-32x32.png</url>
	<title>SQL Server Archives | SQL Solutions Group</title>
	<link>https://sqlsolutionsgroup.com/tag/sql-server/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Security Configuration for Linked Servers</title>
		<link>https://sqlsolutionsgroup.com/linked-server-security/</link>
					<comments>https://sqlsolutionsgroup.com/linked-server-security/#comments</comments>
		
		<dc:creator><![CDATA[Randy Knight]]></dc:creator>
		<pubDate>Wed, 04 Mar 2020 15:41:00 +0000</pubDate>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[linked server]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=3040</guid>

					<description><![CDATA[<p>A few years ago I published an article about how to use linked servers to avoid performance issues. I wanted to follow up on that with a discussion of linked server security configuration because this is another big issue I see all too often with linked servers. The first thing to understand is that all [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/linked-server-security/">Security Configuration for Linked Servers</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A few years ago I published an <a href="https://sqlsolutionsgroup.com/using-linked-servers-the-right-way/">article</a> about how to use linked servers to avoid performance issues. I wanted to follow up on that with a discussion of linked server security configuration because this is another big issue I see all too often with linked servers.</p>
<p>The first thing to understand is that all linked server objects are accessible by everyone in the public database role (normally everybody). So what you are doing when you configure the security for a linked server is determining what the security context of the login will be on the remote server. The permissions of that login on the remote server will ultimately determine what the user can and can’t do.</p>
<hr />
<p class="has-text-align-center" style="font-size: 20px;">A 750-point Health Check from SQL Solutions Group includes a security audit.</p>
<p class="has-text-align-center" style="font-size: 20px;">Find out how healthy your SQL Server estate really is.</p>
<p class="has-text-align-center" style="font-size: 20px;"><a href="https://sqlsolutionsgroup.com/services/sql-health-check/" target="_blank" rel="noopener noreferrer"><span style="text-decoration: underline;">Learn More</span></a></p>
<hr />
<p>What we will be looking at is the <strong>Security</strong> tab of the linked server dialog. We’ll also look at the system stored procedures being executed behind the scenes. You can see these yourself by clicking the <strong>Script</strong> button after configuring the security in the GUI.</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/2016-09-29_15-47-26-1.png"><img fetchpriority="high" decoding="async" class="alignnone wp-image-3047" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/2016-09-29_15-47-26-1-300x271.png" alt="linked server security" width="576" height="521" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/2016-09-29_15-47-26-1-300x271.png 300w, https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/2016-09-29_15-47-26-1.png 750w" sizes="(max-width: 576px) 100vw, 576px" /></a></p>
<h3>Default Behavior for Unmapped Logins</h3>
<p>The top part of the dialog box allows us to map local logins to remote logins. This is fairly straightforward and not where the problem usually lies so we’re going to focus on what happens if there is not a mapped login.</p>
<p>We’ll look at the options one at a time.</p>
<h4>Not be made</h4>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image-1.png"><img decoding="async" class="alignnone wp-image-3047" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image-1.png" alt="linked server security" width="575" height="493" /></a></p>
<p>In this case, all that is done is to create the linked server with no login behavior specified. Without any mapped logins, the linked server is useless.</p>
<pre class="lang:tsql decode:true "><div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">EXEC</span> master.<span class="me1">dbo</span>.<span class="kw3">sp_addlinkedserver</span> @server <span class="sy0">=</span> N<span class="st0">'SERVER1'</span>, @srvproduct<span class="sy0">=</span>N<span class="st0">'SQL Server'</span></pre></div></div></pre>
<p>If we try to execute a linked server query, we get the following results:</p>
<pre class="lang:tsql decode:true "><div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">select</span> name <span class="kw1">from</span> SERVER1.<span class="me1">master</span>.<span class="me1">sys</span>.<span class="me1">databases</span></pre></div></div></pre>
<pre class="lang:tsql decode:true ">Msg 18456, Level 14, State 1, Line 7
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.</pre>
<p>It tried to make an anonymous connection to the remote server which thankfully did not work.</p>
<h4></h4>
<h4>Be made without using a security context</h4>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image-2.png"><img decoding="async" class="wp-image-3209 alignone" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image-2.png" alt="linked server security" width="551" height="478" /></a></p>
<p>In this case, it explicitly creates a mapped login of NULL with @useself = &#8216;False&#8217;. In other words we are explicitly telling it not to pass a security context to the remote server whereas in the first option it tried an anonymous connection.</p>
<pre class="lang:tsql decode:true "><div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">EXEC</span> master.<span class="me1">dbo</span>.<span class="kw3">sp_addlinkedserver</span> @server <span class="sy0">=</span> N<span class="st0">'SERVER1'</span>, @srvproduct<span class="sy0">=</span>N<span class="st0">'SQL Server'</span>, @provider<span class="sy0">=</span>N<span class="st0">'SQLNCLI11'</span>, @datasrc<span class="sy0">=</span>N<span class="st0">'SERVER1'</span>
<span class="kw1">EXEC</span> master.<span class="me1">dbo</span>.<span class="kw3">sp_addlinkedsrvlogin</span> @rmtsrvname<span class="sy0">=</span>N<span class="st0">'SERVER1'</span>,@useself<span class="sy0">=</span>N<span class="st0">'False'</span>,@locallogin<span class="sy0">=NULL</span>,@rmtuser<span class="sy0">=NULL</span>,@rmtpassword<span class="sy0">=NULL</span></pre></div></div></pre>
<p>Let’s see what happens when we execute the query here.</p>
<pre class="lang:tsql decode:true "><div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">select</span> name <span class="kw1">from</span> SERVER1.<span class="me1">master</span>.<span class="me1">sys</span>.<span class="me1">databases</span></pre></div></div></pre>
<pre class="lang:tsql decode:true ">OLE DB provider "SQLNCLI11" for linked server "SERVER1" returned message "Invalid authorization specification".
Msg 7399, Level 16, State 1, Line 7
The OLE DB provider "SQLNCLI11" for linked server "SERVER1" reported an error. Authentication failed.
Msg 7303, Level 16, State 1, Line 7
Cannot initialize the data source object of OLE DB provider "SQLNCLI11" for linked server "SERVER1".</pre>
<p>This option is more secure than the first one simply because it would not work even if the anonymous login worked on the remote server.</p>
<h4></h4>
<h4>Be made using the login’s current security context</h4>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image-3.png"><img loading="lazy" decoding="async" class="wp-image-3209 alignone" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image_thumb-3.png" alt="linked server security" width="552" height="474" /></a></p>
<p>In this case, it is going to pass the security context of the local login to the remote login. If you have to have an option to connect without a mapped login, this is the best option. Note that the call to <strong>sp_addlinkedsrvlogin</strong> is almost the same as the last one. The only difference is that the <strong>@useself</strong> parameter is True.</p>
<pre class="lang:tsql decode:true "><div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img decoding="async" border="0" style="border: 0 none" src="https://sqlsolutionsgroup.com/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="tsql" style="font-family:monospace;"><span class="kw1">EXEC</span> master.<span class="me1">dbo</span>.<span class="kw3">sp_addlinkedserver</span> @server <span class="sy0">=</span> N<span class="st0">'SERVER1'</span>, @srvproduct<span class="sy0">=</span>N<span class="st0">'SERVER1'</span>, @provider<span class="sy0">=</span>N<span class="st0">'SQLNCLI11'</span>, @datasrc<span class="sy0">=</span>N<span class="st0">'SERVER1'</span>
<span class="kw1">EXEC</span> master.<span class="me1">dbo</span>.<span class="kw3">sp_addlinkedsrvlogin</span> @rmtsrvname<span class="sy0">=</span>N<span class="st0">'SERVER1'</span>,@useself<span class="sy0">=</span>N<span class="st0">'True'</span>,@locallogin<span class="sy0">=NULL</span>,@rmtuser<span class="sy0">=NULL</span>,@rmtpassword<span class="sy0">=NULL</span></pre></div></div></pre>
<p>Let’s see what happens when we execute the query here.</p>
<pre class="lang:tsql decode:true "><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">select</span> name <span class="kw1">from</span> SERVER1.<span class="me1">master</span>.<span class="me1">sys</span>.<span class="me1">databases</span></pre></div></div></pre>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image-4.png"><img loading="lazy" decoding="async" class="wp-image-3209 alignone" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image_thumb-4.png" alt="linked server security" width="303" height="301" /></a></p>
<p>It worked this time. The login used on the local server also existed on the remote server so the user connected as if they were directly connecting to the remote server. One thing to note is that with standard logins, this will only work if the login name AND password are the same on both instances. If the login name is the same and the password is different you will get the following error:</p>
<pre class="lang:tsql decode:true ">Msg 18456, Level 14, State 1, Line 11
Login failed for user 'UserA'.</pre>
<p>For this reason, this is a lot easier to deal with when using Active Directory accounts. As long as the AD-based login has permission on both instances it should work just fine, with one caveat. Depending on the configuration of the AD environment you’re in, you may run in what is known as the <a href="https://blogs.technet.microsoft.com/askds/2008/06/13/understanding-kerberos-double-hop/">Kerberos Double Hop issue</a>. Typically you’d be going from a user’s workstation to the local server to the remote server. So two hops. A full discussion of this is beyond the scope of this article but suffice it to say that Kerberos delegation must be properly configured in the environment for this to work.</p>
<h4>Be made using this security context</h4>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image-5.png"><img loading="lazy" decoding="async" class="wp-image-3209 alignone" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image_thumb-5.png" alt="image" width="551" height="501" /></a></p>
<p>This is unfortunately both the most commonly used and the least secure way to address the security configuration of your linked server. What we are saying here is that every user who uses the linked server will be authenticated on the remote server using the credentials provided here. This is RARELY going to be the right thing to do in a secure environment. A user with public on the local server and nothing else will connect to the remote server using this login’s permissions which are usually higher than that. I’ve seen more than one environment using an account like <strong>linkedserver</strong> that exists and is a <strong>sysadmin</strong> on every server!</p>
<pre class="lang:tsql decode:true "><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">EXEC</span> master.<span class="me1">dbo</span>.<span class="kw3">sp_addlinkedserver</span> @server <span class="sy0">=</span> N<span class="st0">'SERVER1'</span>, @srvproduct<span class="sy0">=</span>N<span class="st0">'RKLAPTOPSS'</span>, @provider<span class="sy0">=</span>N<span class="st0">'SQLOLEDB'</span>, @datasrc<span class="sy0">=</span>N<span class="st0">'SERVER1'</span>
<span class="kw1">EXEC</span> master.<span class="me1">dbo</span>.<span class="kw3">sp_addlinkedsrvlogin</span> @rmtsrvname <span class="sy0">=</span> N<span class="st0">'SERVER1'</span>, @locallogin <span class="sy0">=</span> <span class="sy0">NULL</span> , @useself <span class="sy0">=</span> N<span class="st0">'False'</span>, @rmtuser <span class="sy0">=</span> N<span class="st0">'UserA'</span>, @rmtpassword <span class="sy0">=</span> N<span class="st0">'password'</span></pre></div></div></pre>
<p>I won’t bother executing the query for this one because obviously it will work.</p>
<h3>Remote Login Mapping</h3>
<p>We didn’t spend a lot of time on mapped logins because that is fairly straightforward. We can map a local login to a remote login, providing the login name and password on the remote server. This is useful if we can’t control the login name and password on the remote server. It is also useful if we want to control exactly who on the local server can use the remote server. If you have logins mapped here and are using one of the first two options for the default behavior, only these users will have access to the remote server via the linked server.</p>
<p>The Impersonate option is just what it sounds like. This is effectively the same as the <strong>Be made using the login’s current security context</strong> but applies to a specific login, not all of them.</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image-6.png"><img loading="lazy" decoding="async" class="wp-image-3209 alignone" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image_thumb-6.png" alt="image" width="555" height="475" /></a></p>
<p>In this example, the only users who can access the remote server are <strong>UserA</strong> and <strong>UserB</strong>. For <strong>UserA</strong>, we have specified the login name and password on the remote server. <strong>UserB</strong> has the same login name and password on the remote server so impersonation can be used.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/linked-server-security/">Security Configuration for Linked Servers</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/linked-server-security/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Google&#8217;s Cloud SQL for Microsoft SQL Server</title>
		<link>https://sqlsolutionsgroup.com/googles-cloud-sql-for-microsoft-sql-server/</link>
		
		<dc:creator><![CDATA[Jason Russell]]></dc:creator>
		<pubDate>Thu, 26 Sep 2019 11:06:45 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[Google Cloud]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=4367</guid>

					<description><![CDATA[<p>The post <a href="https://sqlsolutionsgroup.com/googles-cloud-sql-for-microsoft-sql-server/">Google&#8217;s Cloud SQL for Microsoft SQL Server</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In late July, Google announced the alpha release of Cloud SQL for Microsoft SQL Server and <a href="https://cloud.google.com/blog/products/databases/new-gcp-database-options-to-power-your-enterprise-workloads">positioned it</a> as a way for enterprises to “experience fully managed SQL Server with built-in high availability and backup capability” in the cloud.</p>
<p>The specs Google outlined for Cloud SQL are nothing to sneeze at:</p>
<ul>
<li>Up to 30 TB of storage</li>
<li>Up to 60,000 IOPS</li>
<li>Up to 416 GB memory per instance</li>
<li>Greater than 99.95% availability</li>
<li>Automated backups, replication, patches and updates</li>
</ul>
<p><img decoding="async" class="alignnone" src="https://www.em360tech.com/wp-content/uploads/2018/09/google-cloud-platform.png" alt="Cloud SQL for Microsoft SQL Server" width="800" /></p>
<p>Clearly the folks at Google are tired of playing third fiddle to AWS and Azure and wanted to up the ante at the cloud-based computing poker table. Google is also going to great lengths to differentiate it’s offering. As <a href="https://techcrunch.com/2019/04/11/google-cloud-makes-some-strong-moves-to-differentiate-itself-from-aws-and-microsoft/">Ron Miller</a> at TechCrunch put it, “Google is trying to position itself in the same way as any cloud vendor going after AWS. They are selling themselves as the hybrid cloud company that can help with your digital transformation.”</p>
<p>Google also announced Anthos as a tool to manage workloads. <a href="https://techobserver.net/2019/04/google-hybrid-cloud-service-aws-azure/">As explained by Urs Hölzle</a>, senior VP for technical infrastructure, “We will support Anthos and AWS and Azure as well, so people get one way to manage their application and that one way works across their on-premise environments and all other clouds.”</p>
<p>Additionally, he said, “I can’t really stress how big a change that is in the industry, because this is really the stack for the next 20 years, meaning that it’s not really about the three different clouds that are all randomly different in small ways. This is the way that makes these three cloud — and actually on-premise environments, too — look the same.”</p>
<h3>Is SQL for Microsoft SQL Server right for your business?</h3>
<p><strong>Translation</strong>: A single managed service for deploying across clouds and no worries about APIs. And it’s far from vaporware: Google has lined up more than 30 hardware and software partners to pull it off. Put it all together and Google may just have a winning hand.</p>
<p>Would you go all-in on Google’s Cloud SQL for Microsoft SQL Server? You can jump in the alpha <a href="https://services.google.com/fb/forms/cloudsqlforsqlservereap/">here</a>. See pricing <a href="https://cloud.google.com/sql/pricing">here</a>.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/googles-cloud-sql-for-microsoft-sql-server/">Google&#8217;s Cloud SQL for Microsoft SQL Server</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>The Strangest Things we&#8217;ve seen in SQL Server</title>
		<link>https://sqlsolutionsgroup.com/strangest-things-in-sql-server/</link>
		
		<dc:creator><![CDATA[Randy Knight]]></dc:creator>
		<pubDate>Wed, 03 Jul 2019 19:23:52 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<category><![CDATA[stranger things]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=4055</guid>

					<description><![CDATA[<p>The post <a href="https://sqlsolutionsgroup.com/strangest-things-in-sql-server/">The Strangest Things we&#8217;ve seen in SQL Server</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2019/07/Strangest_Things.jpg"><img loading="lazy" decoding="async" class="alignleft size-large wp-image-4059" src="https://sqlsolutionsgroup.com/wp-content/uploads/2019/07/Strangest_Things.jpg" alt="" width="1" height="1" /></a></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="504" height="414" class="wp-image-4096" src="https://sqlsolutionsgroup.com/wp-content/uploads/2019/07/Strangest_Things2.jpg" alt="strangest things in sql server" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2019/07/Strangest_Things2.jpg 504w, https://sqlsolutionsgroup.com/wp-content/uploads/2019/07/Strangest_Things2-300x246.jpg 300w" sizes="(max-width: 504px) 100vw, 504px" /></figure>



<p>You think <a href="https://en.wikipedia.org/wiki/Demogorgon_(Dungeons_%26_Dragons)" target="_blank" rel="noopener noreferrer">Demogorgons</a> and Mind Flayers are hard to deal with? Compared to some strange things we&#8217;ve seen in SQL Server databases, they&#8217;re a walk in the park. </p>
<p>Most of the time, SQL Server is a wonderful, robust platform that can handle mountains of data, support all sorts of apps, and generally make life easier. Until it doesn&#8217;t.</p>
<p>And when it doesn&#8217;t, it&#8217;s most often because of strange choices made by users:  bad configuration, bad tuning, bad queries, bad monitoring and maintenance, bad all around. And it&#8217;s not because the people are bad. Most of the time these are honest, well-intentioned&#8230;and strange decisions.</p>
<p>The good news is that we can help you avoid these same mistakes. Over the coming weeks, we&#8217;ll outline for you some of the strangest things we&#8217;ve ever seen in SQL Server, the negative impact they have, and how you can avoid them and stay out of the Data Driven Upside Down.</p>
<p>Friends don&#8217;t lie and we&#8217;ll give you the lowdown. So grab your nail-studded bat and join us next week for our first installment &#8230; a stored procedure being called seven times a millisecond.  That&#8217;s not a typo.  <strong>SEVEN</strong> times a millisecond,  24&#215;7.  That&#8217;s almost <strong>605 MILLION</strong> executions per day.  Truth is stranger than fiction.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/strangest-things-in-sql-server/">The Strangest Things we&#8217;ve seen in SQL Server</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Spectre and Meltdown Exploits</title>
		<link>https://sqlsolutionsgroup.com/spectre-and-meltdown-exploits/</link>
		
		<dc:creator><![CDATA[Randy Knight]]></dc:creator>
		<pubDate>Thu, 18 Jan 2018 14:26:55 +0000</pubDate>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=3160</guid>

					<description><![CDATA[<p>In recent weeks, a significant security risk was exposed. This exploit has been named in two fashions: Spectre and Meltdown. We at SSG feel it important to help disclose the severity and impact of these exploits with this formal release. Unauthorized Memory Disclosure through CPU Side-Channel Attacks (&#8220;Meltdown&#8221; and &#8220;Spectre&#8221;) Overview Vulnerabilities exist in multiple modern CPU architectures [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/spectre-and-meltdown-exploits/">Spectre and Meltdown Exploits</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://https://sqlsolutionsgroup.com"><img loading="lazy" decoding="async" class="alignright wp-image-2682" src="https://sqlsolutionsgroup.com/wp-content/uploads/2015/10/SSG-Event-Logo.png" alt="" width="324" height="199" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2015/10/SSG-Event-Logo.png 384w, https://sqlsolutionsgroup.com/wp-content/uploads/2015/10/SSG-Event-Logo-300x184.png 300w" sizes="(max-width: 324px) 100vw, 324px" /></a></p>
<p>In recent weeks, a significant security risk was exposed. This exploit has been named in two fashions: <strong>Spectre </strong>and <strong>Meltdown</strong>. We at SSG feel it important to help disclose the severity and impact of these exploits with this formal release.</p>
<div>
<p><strong>Unauthorized Memory Disclosure through CPU Side-Channel Attacks</strong></p>
<p>(&#8220;Meltdown&#8221; and &#8220;Spectre&#8221;)</p>
<p><strong>Overview</strong></p>
<p style="padding-left: 30px;">Vulnerabilities exist in multiple modern CPU architectures that could permit an attacker to read the contents of memory.</p>
<p><strong>Affected Products</strong></p>
<p style="padding-left: 30px;">VMWare, SQL Server, Linux, Windows, everything that uses a processor created in the past 15 years.</p>
<p><strong>Details</strong></p>
<p>Full details of the &#8220;Meltdown&#8221; and &#8220;Spectre&#8221; vulnerabilities can be found at the following URLs:</p>
<ul>
<li><a href="https://click.icptrack.com/icp/relay.php?r=&amp;msgid=209755&amp;act=111111&amp;c=1473301&amp;destination=https%3A%2F%2Fmeltdownattack.com%2F" target="_blank" rel="noopener noreferrer">https://meltdownattack.com/</a></li>
<li><a href="https://click.icptrack.com/icp/relay.php?r=&amp;msgid=209755&amp;act=111111&amp;c=1473301&amp;destination=https%3A%2F%2Fgoogleprojectzero.blogspot.co.at%2F2018%2F01%2Freading-privileged-memory-with-side.html" target="_blank" rel="noopener noreferrer">https://googleprojectzero.blogspot.co.at/2018/01/reading-privileged-memory-with-side.html</a></li>
</ul>
<p><strong>Official Releases</strong></p>
<ul>
<li><a href="https://click.icptrack.com/icp/relay.php?r=&amp;msgid=209755&amp;act=111111&amp;c=1473301&amp;destination=https%3A%2F%2Fnewsroom.intel.com%2Fnews%2Fintel-responds-to-security-research-findings%2F" target="_blank" rel="noopener noreferrer">Intel</a> &#8211; <a href="https://click.icptrack.com/icp/relay.php?r=&amp;msgid=209755&amp;act=111111&amp;c=1473301&amp;destination=https%3A%2F%2Fnewsroom.intel.com%2Fnews%2Fintel-responds-to-security-research-findings%2F" target="_blank" rel="noopener noreferrer">https://newsroom.intel.com/news/intel-responds-to-security-research-findings/</a></li>
<li><a href="https://click.icptrack.com/icp/relay.php?r=&amp;msgid=209755&amp;act=111111&amp;c=1473301&amp;destination=https%3A%2F%2Fwww.amd.com%2Fen%2Fcorporate%2Fspeculative-execution" target="_blank" rel="noopener noreferrer">AMD</a> &#8211; <a href="https://click.icptrack.com/icp/relay.php?r=&amp;msgid=209755&amp;act=111111&amp;c=1473301&amp;destination=https%3A%2F%2Fwww.amd.com%2Fen%2Fcorporate%2Fspeculative-execution" target="_blank" rel="noopener noreferrer">https://www.amd.com/en/corporate/speculative-execution</a></li>
<li><a href="https://click.icptrack.com/icp/relay.php?r=&amp;msgid=209755&amp;act=111111&amp;c=1473301&amp;destination=https%3A%2F%2Fdeveloper.arm.com%2Fsupport%2Fsecurity-update" target="_blank" rel="noopener noreferrer">ARM</a> &#8211; <a href="https://click.icptrack.com/icp/relay.php?r=&amp;msgid=209755&amp;act=111111&amp;c=1473301&amp;destination=https%3A%2F%2Fdeveloper.arm.com%2Fsupport%2Fsecurity-update" target="_blank" rel="noopener noreferrer">https://developer.arm.com/support/security-update</a></li>
</ul>
<p>Due to the gravity of these exploits, we at <span style="color: #ff6600;"><strong>SSG </strong></span>recommend patching Hosts, Operating Systems and SQL Server with the appropriate patch(es) being released . Some hosted Cloud solutions have already been patched by AWS and Microsoft Azure – but not all as of yet.</p>
<p><span style="color: #ff6600;"><strong>SSG </strong></span>is prepared to assist in patching your systems to ensure the proper security and integrity of your data and business. Contact us so we can help you mitigate these exploits as soon as possible.</p>
</div>
<p>Email (<a href="mailto:in**@***************up.com" data-original-string="Ry8Xlc3mN70pX5QE9C4/8w==2edyErI7LOw9KqRLu28NMLVHmMDACPOcukeF1hJ1gNqz/LlhrxQlpMDWJrYcIk62nyI1dsp9uCXu1sJCiZ0nH01fYL0ODRHP8I3fEFyBwn9euRzcPPPauG5RombbkFHG8I6lH9/XckbL9UKhj19cVmrU/iVjHMpqf2wV6ffl2zW8yLi9313RDIWN9cLjCacC5XRhtRPD2kaFzWeIIW3zg+Wm+MY6nuWpczNFgqWzkCkbTbtyP62f/fJHLJeQmtgaruha8/XxeiyE8yo7XE01JEC5A==" title="This contact has been encoded by Anti-Spam by CleanTalk. Click to decode. To finish the decoding make sure that JavaScript is enabled in your browser.?subject=Spectre%20and%20Meltdown%20Patching&amp;body=I%20would%20like%20to%20schedule%20a%20consultant%20to%20assist%20with%20the%20patching%20of%20my%20server%20environment." target="_blank" rel="noopener noreferrer"><span 
                data-original-string='PrGoZCs56IYuSGCXqtmCTg==2ed4q35XTmlQCpRy3c4oLjXSvQA/8I5zZ+VWH/ZDCWdsto='
                class='apbct-email-encoder'
                title='This contact has been encoded by Anti-Spam by CleanTalk. Click to decode. To finish the decoding make sure that JavaScript is enabled in your browser.'>in<span class="apbct-blur">**</span>@<span class="apbct-blur">***************</span>up.com</span></a>) us now to schedule one of our consultants to help you secure your servers.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/spectre-and-meltdown-exploits/">Spectre and Meltdown Exploits</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>When is Max Memory in SQL Server not Max Memory?</title>
		<link>https://sqlsolutionsgroup.com/max-memory/</link>
		
		<dc:creator><![CDATA[Ben Miller]]></dc:creator>
		<pubDate>Tue, 16 Dec 2014 03:12:16 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[Memory]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/?p=1871</guid>

					<description><![CDATA[<p>When thinking about configuration parameters for SQL Server, one of the first ones to look at is the sp_configure option ‘max server memory’.  In versions up to SQL Server 2008 R2, max memory referred to physical memory. The versions indicated that the max memory that it could use was 64GB (note: SQL 2008 R2 and [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/max-memory/">When is Max Memory in SQL Server not Max Memory?</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When thinking about configuration parameters for SQL Server, one of the first ones to look at is the sp_configure option ‘max server memory’.  In versions up to SQL Server 2008 R2, max memory referred to physical memory. The versions indicated that the max memory that it could use was 64GB (note: SQL 2008 R2 and below).</p>
<p><a href="https://support2.microsoft.com/kb/2663912/en-us?sd=rss&amp;spid=1044"><img loading="lazy" decoding="async" class="aligncenter wp-image-1875 size-full" src="https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/MaxMem_gauge.png" alt="Max memory" width="500" height="375" srcset="https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/MaxMem_gauge.png 500w, https://sqlsolutionsgroup.com/wp-content/uploads/2014/12/MaxMem_gauge-300x225.png 300w" sizes="(max-width: 500px) 100vw, 500px" /></a></p>
<h2>Changes to Max Memory</h2>
<p>In SQL Server 2012, according to this <a href="https://support2.microsoft.com/kb/2663912/en-us?sd=rss&amp;spid=1044" target="_blank" rel="noopener noreferrer">KB Article</a> in the bottom paragraph of the article, after it explains the changes in SQL 2012 for what is included in the governance of max server memory, it explains that in SQL Server 2012 the limitation of the max physical memory is all about Buffer Pool (database cache) and not other things.</p>
<p>In other words, if I have a server with 96 GB of RAM and I put SQL 2012 Standard edition on it, I could set ‘max server memory’ to a number higher than 64 GB and SQL Server would limit Buffer Pool to 64 GB and could use memory higher than 64GB for other things outside the buffer pool. This may not sound like a big deal, but think about wanting more buffer pool but still needing to fit inside the memory limits.</p>
<p>This new allocation allows SQL Server 2012 and higher to use up to the physical limit specified by SQL Server 2012 (Standard = 64GB) and SQL Server 2014 (Standard = 128GB), and to specify a higher number for max server memory than the specified limit of RAM. In this configuration SQL Server will use up to 64GB/128GB for Buffer Pool and memory above that for other parts of SQL Server allocations.</p>
<p>In Enterprise Edition you are limited in RAM only in the limitations of the Operating Systems ability to address that amount of RAM so other editions of SQL Server are the benefactors of this feature.</p>
<p>I would not think of this as a silver bullet, but I think in many cases you can extend the usefulness of the feature if your servers have more RAM than SQL Server can address for the Buffer Pool if you are using Standard and below.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/max-memory/">When is Max Memory in SQL Server not Max Memory?</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using Linked Servers the Right Way</title>
		<link>https://sqlsolutionsgroup.com/using-linked-servers-the-right-way/</link>
					<comments>https://sqlsolutionsgroup.com/using-linked-servers-the-right-way/#comments</comments>
		
		<dc:creator><![CDATA[Randy Knight]]></dc:creator>
		<pubDate>Sun, 28 Oct 2012 17:36:16 +0000</pubDate>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<category><![CDATA[T-SQL]]></category>
		<guid isPermaLink="false">http://sqlsolutionsgroup.com/blog/?p=181</guid>

					<description><![CDATA[<p>Linked Servers are a very popular way to access distributed data in environments with lots of SQL Server instances on different serves, or even on other Database Management Systems like Oracle or MySQL. While linked servers can be very useful if used correctly, I have found that more often than not, they are not used correctly [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/using-linked-servers-the-right-way/">Using Linked Servers the Right Way</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Linked Servers are a very popular way to access distributed data in environments with lots of SQL Server instances on different serves, or even on other Database Management Systems like Oracle or MySQL. While linked servers can be very useful if used correctly, I have found that more often than not, they are not used correctly and are a source of lots of performance problems.  In this article we’ll take a look at using linked servers the right way (and a few wrong ones).</p>
<h3><strong>Linked Server Review</strong></h3>
<p>To start with, lets look at how a linked server works.  We configure a linked server by specifying the remote data source and a name for the sever.</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/linked1-1.png"><img loading="lazy" decoding="async" style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="linked1" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/linked1_thumb.png" alt="linked1" width="509" height="462" border="0" /></a></p>
<p>This allows us to use the linked server name <strong>ADVENTUREWORKS</strong> to access the <strong>AdventureWorks</strong> database on the instance <strong>RKLAPTOPSS</strong>.  Note that the Linked Server name can be whatever we want it to.  It does not have to be the name of the instance. I prefer this practice because you can use the same linked server name in multiple environments (Development, QA, Production, etc.)</p>
<p>Authentication settings have to be configured as well.</p>
<p><a href="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image.png"><img loading="lazy" decoding="async" style="background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;" title="image" src="https://sqlsolutionsgroup.com/wp-content/uploads/2016/09/image_thumb.png" alt="image" width="506" height="457" border="0" /></a></p>
<p>In this case, I am saying to just pass through the login’s security context to the remote server.  I could also choose to always use a certain security context or to map local login’s to remote logins. The security implications of these choices are beyond the scope of this post but the most important thing is that in most cases Options 2 and 4 should not be used.</p>
<hr />
<p class="has-text-align-center" style="font-size: 20px;">With the Remote DBA managed service from</p>
<p class="has-text-align-center" style="font-size: 20px;">SQL Solutions Group, we do your database dirty</p>
<p class="has-text-align-center" style="font-size: 20px;">work, freeing up your team for projects</p>
<p class="has-text-align-center" style="font-size: 20px;">that impact the bottom line.</p>
<p class="has-text-align-center" style="font-size: 20px;"><a href="https://sqlsolutionsgroup.com/services/remote-dba-services/" target="_blank" rel="noopener noreferrer"><span style="text-decoration: underline;">Learn More</span></a></p>
<hr />
<h3><strong>Four Part Naming in Linked Servers</strong></h3>
<p>Now that we have a linked server set up, we can access it from the local SQL Server instance.  The most common way to do this is to use four part names to refer to objects on the remote server.</p>
<blockquote><p><em>&lt;LinkedServerName&gt;.&lt;DatabaseName&gt;.&lt;Schema&gt;.&lt;Object&gt;</em></p></blockquote>
<pre class="csharpcode"><span class="kwrd">SELECT</span> *
<span class="kwrd">FROM</span> ADVENTUREWORKS.AdventureWorks.HumanResources.Employee
<span class="kwrd">WHERE</span> Gender = <span class="str">'M'</span></pre>
<p>While this is the most popular way to use Linked Servers, it is also the worst way in terms of performance.  To understand this, you need to always ask the following question: “Where will the query be optimized?”</p>
<p>In this case, the optimizer on the local server will determine the execution plan.  But it doesn’t know anything about indexes and statistics that exist on the Employee table on the remote server.  There may well be an index on Gender which could be taken advantage of, but the local optimizer has no way to know that.   So this query will result in a table scan, every time, regardless of remote indexes. In addition, all of the data will be sent across the network only to be filtered for Gender on the local system.</p>
<p><strong>OPENQUERY()</strong></p>
<p>A better way to do this is to use a function like OPENQUERY().  Essentially what we are doing is executing a remote query on the linked server and just asking for the results back.</p>
<pre class="csharpcode"><span class="kwrd">SELECT</span> *
<span class="kwrd">FROM</span> <span class="kwrd">OPENQUERY</span>
   (
    ADVENTUREWORKS,
    <span class="str">'SELECT * FROM AdventureWorks.HumanResources.Employee WHERE Gender = '</span><span class="str">'M'</span><span class="str">''</span>
   )</pre>
<p>The function takes two parameters.  The remote server to execute the query on, and the query itself.  Note that this is remotely executing so if the server was to another DBMS, you’d want the query written in that engine’s flavor of SQL.</p>
<p>This is a simple example, but imagine if the remote table had a million plus rows.  The inefficient table scan plus bringing all that over the network so that it can be filtered locally.  I have “fixed” queries that were taking 12+ hours to run and reduced the time to just minutes by making this simple change to the code.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/using-linked-servers-the-right-way/">Using Linked Servers the Right Way</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/using-linked-servers-the-right-way/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Saturday #120 &#8211; Orange County, CA</title>
		<link>https://sqlsolutionsgroup.com/sql-saturday-120-orange-county-ca-2/</link>
		
		<dc:creator><![CDATA[Randy Knight]]></dc:creator>
		<pubDate>Mon, 19 Mar 2012 10:00:04 +0000</pubDate>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[California]]></category>
		<category><![CDATA[SQL Saturday]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<category><![CDATA[XML]]></category>
		<guid isPermaLink="false">http://www.www.sqlsolutionsgroup.com/blog/?p=148</guid>

					<description><![CDATA[<p>Looking forward to heading to Southern California this weekend for SQL Saturday #120 in Huntington Beach.  They always put on a great event and you can&#8217;t beat the location.  Not to mention that it is very close to where I grew up so I get to see some old friends while I&#8217;m there. I will [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/sql-saturday-120-orange-county-ca-2/">SQL Saturday #120 &#8211; Orange County, CA</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Looking forward to heading to Southern California this weekend for SQL Saturday #120 in Huntington Beach.  They always put on a great event and you can&#8217;t beat the location.  Not to mention that it is very close to where I grew up so I get to see some old friends while I&#8217;m there.</p>
<p>I will be doing two sessions at this event:</p>
<ul>
<li><a href="https://sqlsaturday.com/viewsession.aspx?sat=120&amp;sessionid=6820">Understanding Transaction Isolation Levels</a></li>
<li><a href="https://sqlsaturday.com/viewsession.aspx?sat=120&amp;sessionid=6820">Understanding SQL Server XML Features</a></li>
</ul>
<p>Of course there are many other fantastic sessions as well as a pre-conference session all day on Friday.</p>
<p>Hope to see you there!</p>
<p>The post <a href="https://sqlsolutionsgroup.com/sql-saturday-120-orange-county-ca-2/">SQL Saturday #120 &#8211; Orange County, CA</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Utah Code Camp Spring 2012</title>
		<link>https://sqlsolutionsgroup.com/utah-code-camp-spring-2012/</link>
		
		<dc:creator><![CDATA[Randy Knight]]></dc:creator>
		<pubDate>Tue, 13 Mar 2012 02:19:47 +0000</pubDate>
				<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[Code Camp]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://www.www.sqlsolutionsgroup.com/blog/?p=139</guid>

					<description><![CDATA[<p>This last Saturday was the most recent iteration of Utah Code Camp  and I have to say it was a resounding success.  In addition to speaking, I was invited to participate in an &#8220;Ask a DBA&#8221; panel discussion and also had the opportunity to have SQL Solutions Group sponsor the event.  So it was a [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/utah-code-camp-spring-2012/">Utah Code Camp Spring 2012</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This last Saturday was the most recent iteration of <a title="Utah Code Camp" href="https://utahgeekevents.com/Sessions">Utah Code Camp </a> and I have to say it was a resounding success.  In addition to speaking, I was invited to participate in an &#8220;Ask a DBA&#8221; panel discussion and also had the opportunity to have SQL Solutions Group sponsor the event.  So it was a busy day.</p>
<p>My first session was the last one before lunch and is one of my favorites to give.  <a title="But it Worked in Dev!" href="https://utahgeekevents.com/Downloads/Download?DownloadID=88">But it worked in Dev!  SQL Server Performance</a><a title="But it Worked in Dev!" href="https://utahgeekevents.com/Downloads/Download?DownloadID=88"> for Developers</a> is always a lively session with good discussion.  Given that this was a code camp, the audience was almost all developers so it worked out great.  Based on the discussions both during and after the session, I am confident more than a few developers will be looking at their SQL more closely than they did before.  There was one participant who was actually pretty shaken up when learning what &#8220;NOLOCK&#8221; really does and does not do.  I think I may have ruined his weekend but as they say, forewarned is forearmed.</p>
<p>Thanks to Platinum Sponsor <a title="Domo" href="https://www.domo.com/">Domo</a>, we had a great lunch catered by Famous Dave&#8217;s.  Then it was on to afternoon sessions.  I finished the day participating in a panel discussion of DBA&#8217;s called &#8220;Ask a DBA&#8221;.  This was an informal session with DBA&#8217;s representing SQL Server, Oracle, and mySQL.  Most of the attendees were SQL Server users so that is where the discussion seemed to focus but it was great hearing the contrast between the systems anyway.  There were some great questions regarding scalability (up vs. out), NoSQL, and many others. Kudos to <a href="https://sqlasylum.wordpress.com/">Pat Wright</a> for putting this together.</p>
<p>The most impressive thing about this Code Camp was the attendance.  I believe 380 was the offical count and that is almost double what they had last year.  As a sponsor, this was fantastic as we had a ton of people come by the booth and made some good contacts, both as prospective clients and as prospective consultants.  Since the gating factor for the growth of my business has been more in relation to having the consultants to do the work than in having enough work to do, this part is important.</p>
<p>Thanks to the folks at <a title="Utah Geek Events" href="https://utahgeekevents.com/">Utah Geek Events</a> who as always, did a fantastic job putting on the event.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://sqlsolutionsgroup.com/utah-code-camp-spring-2012/">Utah Code Camp Spring 2012</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Truncate Tables that have Foreign Keys</title>
		<link>https://sqlsolutionsgroup.com/truncate-tables-that-have-foreign-keys/</link>
					<comments>https://sqlsolutionsgroup.com/truncate-tables-that-have-foreign-keys/#comments</comments>
		
		<dc:creator><![CDATA[Randy Knight]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 14:55:41 +0000</pubDate>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[constraint]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<guid isPermaLink="false">http://www.www.sqlsolutionsgroup.com/blog/?p=104</guid>

					<description><![CDATA[<p>One of the issues I often run into is the need to truncate very large tables. But if there is a foreign key constraint on the table, SQL Server will not allow a truncate, only a delete. This is fine for smaller tables but if the table has millions of rows, we want to do [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/truncate-tables-that-have-foreign-keys/">Truncate Tables that have Foreign Keys</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">One of the issues I often run into is the need to truncate very large tables. But if there is a foreign key constraint on the table, SQL Server will not allow a truncate, only a delete. This is fine for smaller tables but if the table has millions of rows, we want to do a truncate vs. a delete, as a truncate is minimally logged and much faster. Unfortunately, disabling the constraints is not enough. It has to be dropped. So I put together a script to do this for me.</p>



<h3 class="wp-block-heading"><strong>Save the Definition</strong></h3>



<p class="wp-block-paragraph">The first thing we need to do is document all the foreign keys so we can re-create them later. I do this by getting the constraint definitions from a couple of DMV&#8217;s and storing the pertinent data in a temporary table. Note that if for some reason you lost your connection, you would lose this table so you could give some consideration to using a permanent table.</p>



<pre class="wp-block-code"><code class="language-sql" lang="sql"> 1:  SELECT
    2:      fk.name AS FKName
    3:      ,OBJECT_NAME(fk.parent_object_id) AS TableName
    4:      ,OBJECT_NAME(fk.referenced_object_id) AS ReferencesTable
    5:      ,COL_NAME(fk.parent_object_id,fkc.parent_column_id) AS ConstraintColumn
    6:      ,COL_NAME(fk.referenced_object_id,referenced_column_id) AS ReferenceColumn
    7:  INTO #fk
    8:  FROM sys.foreign_keys fk
    9:      INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id
   10:  ORDER BY 1</code></pre>



<p class="wp-block-paragraph">&nbsp;</p>



<h3 class="wp-block-heading"><strong>Drop the Constraints</strong></h3>



<p class="wp-block-paragraph">Now we can use dynamic SQL to drop the constraints</p>



<pre class="wp-block-code"><code class="language-sql" lang="sql">  1:  DECLARE 
   2:      @FKName sysname 
   3:      ,@TableName sysname 
   4:      ,@ReferencesTableName sysname 
   5:      ,@ConstraintColumn sysname 
   6:      ,@ReferenceColumn sysname 
   7:      ,@SQL NVARCHAR(4000) 
   8:   
   9:  DECLARE cur CURSOR FOR 
  10:      SELECT FKName, TableName FROM #fk 
  11:  OPEN cur 
  12:  WHILE 1=1 
  13:  BEGIN     
  14:      FETCH NEXT FROM cur INTO @FKName, @TableName 
  15:      IF @@fetch_status !=0 
  16:          BREAK 
  17:   
  18:      SET @SQL = 'alter table ' + @TableName + ' DROP CONSTRAINT ' + @FKName 
  19:      EXEC dbo.sp_executesql @SQL 
  20:  END     
  21:  CLOSE cur 
  22:  DEALLOCATE cur 
  23:  GO</code></pre>



<p class="wp-block-paragraph"><style type="text/css"> &amp;lt;p>.csharpcode, .csharpcode pre&amp;lt;br /> {&amp;lt;br /> font-size: small;&amp;lt;br /> color: black;&amp;lt;br /> font-family: consolas, "Courier New", courier, monospace;&amp;lt;br /> background-color: #ffffff;&amp;lt;br /> /*white-space: pre;*/&amp;lt;br /> }&amp;lt;br /> .csharpcode pre { margin: 0em; }&amp;lt;br /> .csharpcode .rem { color: #008000; }&amp;lt;br /> .csharpcode .kwrd { color: #0000ff; }&amp;lt;br /> .csharpcode .str { color: #006080; }&amp;lt;br /> .csharpcode .op { color: #0000c0; }&amp;lt;br /> .csharpcode .preproc { color: #cc6633; }&amp;lt;br /> .csharpcode .asp { background-color: #ffff00; }&amp;lt;br /> .csharpcode .html { color: #800000; }&amp;lt;br /> .csharpcode .attr { color: #ff0000; }&amp;lt;br /> .csharpcode .alt&amp;lt;br /> {&amp;lt;br /> background-color: #f4f4f4;&amp;lt;br /> width: 100%;&amp;lt;br /> margin: 0em;&amp;lt;br /> }&amp;lt;br /> .csharpcode .lnum { color: #606060; }</style></p>



<h3 class="wp-block-heading"><strong>Truncate the Tables</strong></h3>



<p class="wp-block-paragraph">Using the undocumented stored procedure <em>sp_msforeachtabled</em> we can easily truncate all the tables now.</p>



<pre class="wp-block-code"><code class="language-sql" lang="sql">   1:  exec sp_MSforeachtable 'truncate table ?' </code></pre>



<h3 class="wp-block-heading"><strong>Re-Create the Constraints</strong></h3>



<p class="wp-block-paragraph">Finally, we use dynamic SQL to re-create the constraints</p>



<pre class="wp-block-code"><code class="language-sql" lang="sql">1:  DECLARE 
   2:      @FKName sysname 
   3:      ,@TableName sysname 
   4:      ,@ReferencesTableName sysname 
   5:      ,@ConstraintColumn sysname 
   6:      ,@ReferenceColumn sysname 
   7:      ,@SQL NVARCHAR(4000) 
   8:   
   9:  DECLARE cur CURSOR FOR 
  10:      SELECT * FROM #fk 
  11:  OPEN cur 
  12:  WHILE 1=1 
  13:  BEGIN     
  14:      FETCH NEXT FROM cur INTO @FKName, @TableName, @ReferencesTableName, 
  15:          @ConstraintColumn, @ReferenceColumn 
  16:      IF @@fetch_status !=0 
  17:          BREAK 
  18:   
  19:      SET @SQL = 'alter table ' + @TableName + ' ADD CONSTRAINT ' + @FKName + 
  20:          ' FOREIGN KEY(' + @ConstraintColumn + ') REFERENCES ' 
  21:          + @ReferencesTableName + '(' + @ReferenceColumn + ')' 
  22:      EXEC dbo.sp_executesql @SQL 
  23:  END     
  24:  CLOSE cur 
  25:  DEALLOCATE cur 
  26:  GO</code></pre>



<p class="wp-block-paragraph"><style type="text/css">
.csharpcode, .csharpcode pre<br />
{<br />
	font-size: small;<br />
	color: black;<br />
	font-family: consolas, "Courier New", courier, monospace;<br />
	background-color: #ffffff;<br />
	/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
	background-color: #f4f4f4;<br />
	width: 100%;<br />
	margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; }</style> <style type="text/css">
<p>.csharpcode, .csharpcode pre<br />
{<br />
	font-size: small;<br />
	color: black;<br />
	font-family: consolas, "Courier New", courier, monospace;<br />
	background-color: #ffffff;<br />
	/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
	background-color: #f4f4f4;<br />
	width: 100%;<br />
	margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; }</style></p>



<h4 class="wp-block-heading"><strong>Finally a quick script to check the final row counts</strong></h4>



<pre class="wp-block-code"><code class="language-sql" lang="sql"> 1:  create table #rowcount (tablename varchar(128), rowcnt int) 
   2:   
   3:  exec sp_MSforeachtable 'insert into #rowcount select ''?'', count(*) from ?' 
   4:   
   5:  select * from #rowcount order by tablename 
   6:   
   7:  DROP TABLE #rowcount 
   8:   </code></pre>



<p class="wp-block-paragraph"><style type="text/css">
.csharpcode, .csharpcode pre<br />
{<br />
	font-size: small;<br />
	color: black;<br />
	font-family: consolas, "Courier New", courier, monospace;<br />
	background-color: #ffffff;<br />
	/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
	background-color: #f4f4f4;<br />
	width: 100%;<br />
	margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; }</style></p>
<p>The post <a href="https://sqlsolutionsgroup.com/truncate-tables-that-have-foreign-keys/">Truncate Tables that have Foreign Keys</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sqlsolutionsgroup.com/truncate-tables-that-have-foreign-keys/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Utah Code Camp</title>
		<link>https://sqlsolutionsgroup.com/utah-code-camp/</link>
		
		<dc:creator><![CDATA[Randy Knight]]></dc:creator>
		<pubDate>Wed, 23 Mar 2011 10:24:26 +0000</pubDate>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Group]]></category>
		<category><![CDATA[#microsftcertifedmaster]]></category>
		<category><![CDATA[#microsftpartner]]></category>
		<category><![CDATA[#SQLAB]]></category>
		<category><![CDATA[#SQlatino]]></category>
		<category><![CDATA[#SQlatinoamerica]]></category>
		<category><![CDATA[#sqldatabase]]></category>
		<category><![CDATA[#sqldeveloper]]></category>
		<category><![CDATA[#SQLgroupie]]></category>
		<category><![CDATA[#sqlimer]]></category>
		<category><![CDATA[#sqlimerbymay]]></category>
		<category><![CDATA[#sqlinjection]]></category>
		<category><![CDATA[#sqlinternals]]></category>
		<category><![CDATA[#sqlite]]></category>
		<category><![CDATA[#sqlite3]]></category>
		<category><![CDATA[#SQLLearning]]></category>
		<category><![CDATA[#SQLMagazine]]></category>
		<category><![CDATA[#sqlmanagementstudio]]></category>
		<category><![CDATA[#sqlmanager]]></category>
		<category><![CDATA[#Sqlmap]]></category>
		<category><![CDATA[#sqlrun]]></category>
		<category><![CDATA[#sqlsaturday2017]]></category>
		<category><![CDATA[#sqlsatvienna]]></category>
		<category><![CDATA[#sqlserver]]></category>
		<category><![CDATA[#SQLserver2012]]></category>
		<category><![CDATA[#sqlserver2014]]></category>
		<category><![CDATA[#sqlserver2017]]></category>
		<category><![CDATA[#sqlserver2022]]></category>
		<category><![CDATA[#SQLServeronLinux]]></category>
		<category><![CDATA[#SQLsolutionsgroup]]></category>
		<category><![CDATA[#SQLTraining]]></category>
		<category><![CDATA[#SQLYog]]></category>
		<category><![CDATA[Code Camp]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLPASS]]></category>
		<category><![CDATA[SQLSaturday]]></category>
		<category><![CDATA[SSG]]></category>
		<category><![CDATA[Utah]]></category>
		<category><![CDATA[XML]]></category>
		<guid isPermaLink="false">http://www.www.sqlsolutionsgroup.com/blog/?p=94</guid>

					<description><![CDATA[<p>I&#8217;ve been doing a lot of traveling lately speakng at SQL Saturday events.  This last weekend it was my great pleasure to speak at Utah Code Camp, a local event.  Not only was it nice to be local, but I really enjoyed the code camp.  Unfortunately I didn&#8217;t get to stay all day as I [&#8230;]</p>
<p>The post <a href="https://sqlsolutionsgroup.com/utah-code-camp/">Utah Code Camp</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of traveling lately speakng at SQL Saturday events.  This last weekend it was my great pleasure to speak at Utah Code Camp, a local event.  Not only was it nice to be local, but I really enjoyed the code camp.  Unfortunately I didn&#8217;t get to stay all day as I had some other things going on as I have been gone a lot of Saturdays lately but I rally enjoyed the time I was there.  I prepared a new session for the event, which I am also doing at SQL Saturday in Chicago this weekend (3/26).  The session is titled &#8220;Hierarchical data in my database?  Understanding SQL Server XML Features&#8221;.  It is a quick overview of the various ways to get XML in and out of SQL Server, the T-SQL XQuery implementation, etc.  A new session is always a bit worrisome as no matter how much you prepare and practice, you&#8217;re not real sure how the timing will go.  But it seemed to go well, I had several positive comments from attendees afterwards, and I finished with about 5 minutes to spare.  So not a bad first outing at all.</p>
<p>The post <a href="https://sqlsolutionsgroup.com/utah-code-camp/">Utah Code Camp</a> appeared first on <a href="https://sqlsolutionsgroup.com">SQL Solutions Group</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
