<?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 Archives - IT Blog Site</title>
	<atom:link href="https://www.lavatelli.it/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lavatelli.it/category/sql/</link>
	<description>Lavatelli IT Blog Site</description>
	<lastBuildDate>Tue, 27 May 2014 11:35:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>

<image>
	<url>https://www.lavatelli.it/wp-content/uploads/2019/02/ice_dragon-150x145.gif</url>
	<title>SQL Archives - IT Blog Site</title>
	<link>https://www.lavatelli.it/category/sql/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to kill all connections to a SQL Server DB</title>
		<link>https://www.lavatelli.it/how-do-you-kill-all-current-connections-to-a-sql-server-database/</link>
		
		<dc:creator><![CDATA[Franz]]></dc:creator>
		<pubDate>Thu, 16 Jan 2014 13:45:01 +0000</pubDate>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[kill connection]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sql kill database]]></category>
		<category><![CDATA[sql server]]></category>
		<guid isPermaLink="false">http://www.lavatelli.it/?p=302</guid>

					<description><![CDATA[<p>Script to accomplish this, replace &#8216;DB_NAME&#8217; with the database to kill all connections to: USE master GO SET NOCOUNT ON DECLARE @DBName varchar(50) DECLARE @spidstr varchar(8000) DECLARE @ConnKilled smallint SET @ConnKilled=0 SET @spidstr = '' Set @DBName = 'DB_NAME' IF db_id(@DBName) &#60; 4 BEGIN PRINT 'Connections to system databases cannot be killed' RETURN END SELECT ...</p>
<p>The post <a href="https://www.lavatelli.it/how-do-you-kill-all-current-connections-to-a-sql-server-database/">How to kill all connections to a SQL Server DB</a> appeared first on <a href="https://www.lavatelli.it">IT Blog Site</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="entry">
<p>Script to accomplish this, replace &#8216;DB_NAME&#8217; with the database to kill all connections to:</p>
<pre><code>USE master
GO

SET NOCOUNT ON
DECLARE @DBName varchar(50)
DECLARE @spidstr varchar(8000)
DECLARE @ConnKilled smallint
SET @ConnKilled=0
SET @spidstr = ''

Set @DBName = 'DB_NAME'
IF db_id(@DBName) &lt; 4
BEGIN
PRINT 'Connections to system databases cannot be killed'
RETURN
END
SELECT @spidstr=coalesce(@spidstr,',' )+'kill '+convert(varchar, spid)+ '; '
FROM master..sysprocesses WHERE dbid=db_id(@DBName)

IF LEN(@spidstr) &gt; 0
BEGIN
EXEC(@spidstr)
SELECT @ConnKilled = COUNT(1)
FROM master..sysprocesses WHERE dbid=db_id(@DBName)
END</code></pre>
</div>
<p><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fhow-do-you-kill-all-current-connections-to-a-sql-server-database%2F&amp;linkname=How%20to%20kill%20all%20connections%20to%20a%20SQL%20Server%20DB" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fhow-do-you-kill-all-current-connections-to-a-sql-server-database%2F&amp;linkname=How%20to%20kill%20all%20connections%20to%20a%20SQL%20Server%20DB" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fhow-do-you-kill-all-current-connections-to-a-sql-server-database%2F&amp;linkname=How%20to%20kill%20all%20connections%20to%20a%20SQL%20Server%20DB" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fhow-do-you-kill-all-current-connections-to-a-sql-server-database%2F&amp;linkname=How%20to%20kill%20all%20connections%20to%20a%20SQL%20Server%20DB" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fhow-do-you-kill-all-current-connections-to-a-sql-server-database%2F&amp;linkname=How%20to%20kill%20all%20connections%20to%20a%20SQL%20Server%20DB" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.lavatelli.it%2Fhow-do-you-kill-all-current-connections-to-a-sql-server-database%2F&#038;title=How%20to%20kill%20all%20connections%20to%20a%20SQL%20Server%20DB" data-a2a-url="https://www.lavatelli.it/how-do-you-kill-all-current-connections-to-a-sql-server-database/" data-a2a-title="How to kill all connections to a SQL Server DB"></a></p><p>The post <a href="https://www.lavatelli.it/how-do-you-kill-all-current-connections-to-a-sql-server-database/">How to kill all connections to a SQL Server DB</a> appeared first on <a href="https://www.lavatelli.it">IT Blog Site</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Check all SQL table size</title>
		<link>https://www.lavatelli.it/check-all-table-size/</link>
		
		<dc:creator><![CDATA[Franz]]></dc:creator>
		<pubDate>Mon, 29 Jul 2013 21:13:12 +0000</pubDate>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[size]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[view]]></category>
		<guid isPermaLink="false">http://www.lavatelli.it/?p=297</guid>

					<description><![CDATA[<p>With this simple query, you can find size of all tables on sql database EXEC sp_MSforeachtable @command1=&#8221;EXEC sp_spaceused &#8216;?'&#8221; otherwise if you need to check a single table you can use the following query exec sp_spaceused tablename;</p>
<p>The post <a href="https://www.lavatelli.it/check-all-table-size/">Check all SQL table size</a> appeared first on <a href="https://www.lavatelli.it">IT Blog Site</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="entry">
<p>With this simple query, you can find size of all tables on sql database</p>
<p>EXEC sp_MSforeachtable @command1=&#8221;EXEC sp_spaceused &#8216;?'&#8221;</p>
<p>otherwise if you need to check a single table</p>
<p>you can use the following query</p>
<p><code>exec sp_spaceused <em>tablename</em>;</code></p>
</div>
<p><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fcheck-all-table-size%2F&amp;linkname=Check%20all%20SQL%20table%20size" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fcheck-all-table-size%2F&amp;linkname=Check%20all%20SQL%20table%20size" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fcheck-all-table-size%2F&amp;linkname=Check%20all%20SQL%20table%20size" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fcheck-all-table-size%2F&amp;linkname=Check%20all%20SQL%20table%20size" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Fcheck-all-table-size%2F&amp;linkname=Check%20all%20SQL%20table%20size" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.lavatelli.it%2Fcheck-all-table-size%2F&#038;title=Check%20all%20SQL%20table%20size" data-a2a-url="https://www.lavatelli.it/check-all-table-size/" data-a2a-title="Check all SQL table size"></a></p><p>The post <a href="https://www.lavatelli.it/check-all-table-size/">Check all SQL table size</a> appeared first on <a href="https://www.lavatelli.it">IT Blog Site</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Orphaned Users</title>
		<link>https://www.lavatelli.it/orphaned-users/</link>
		
		<dc:creator><![CDATA[Franz]]></dc:creator>
		<pubDate>Mon, 16 Jan 2012 15:49:11 +0000</pubDate>
				<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">http://www.lavatelli.it/?p=213</guid>

					<description><![CDATA[<p>If you migrate DB between sql server or if you restore a DB on new sql server, you may get orphaned sql user. To detect if you&#8217;re in this condition, run this sp. EXEC sp_change_users_login &#8216;Report&#8217; This will report all login inserted into db and not in sql server. If you already have a login ...</p>
<p>The post <a href="https://www.lavatelli.it/orphaned-users/">Orphaned Users</a> appeared first on <a href="https://www.lavatelli.it">IT Blog Site</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="entry">
<p>If you migrate DB between sql server or if you restore a DB on new sql server, you may get orphaned sql user.<br />
To detect if you&#8217;re in this condition, run this sp.<br />
EXEC sp_change_users_login &#8216;Report&#8217;<br />
This will report all login inserted into db and not in sql server.</p>
<p>If you already have a login id and password for this user, fix it by doing:</p>
<p>EXEC sp_change_users_login &#8216;Auto_Fix&#8217;, &#8216;user&#8217;<br />
&#8220;Auto Fix&#8221; work only with windows users!</p>
<p>If you want to create a new login id and password for this user, fix it by doing:</p>
<p>EXEC sp_change_users_login &#8216;Auto_Fix&#8217;, &#8216;user&#8217;, &#8216;login&#8217;, &#8216;password&#8217;</p>
</div>
<p><a class="a2a_button_email" href="https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Forphaned-users%2F&amp;linkname=Orphaned%20Users" title="Email" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Forphaned-users%2F&amp;linkname=Orphaned%20Users" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Forphaned-users%2F&amp;linkname=Orphaned%20Users" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Forphaned-users%2F&amp;linkname=Orphaned%20Users" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.lavatelli.it%2Forphaned-users%2F&amp;linkname=Orphaned%20Users" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.lavatelli.it%2Forphaned-users%2F&#038;title=Orphaned%20Users" data-a2a-url="https://www.lavatelli.it/orphaned-users/" data-a2a-title="Orphaned Users"></a></p><p>The post <a href="https://www.lavatelli.it/orphaned-users/">Orphaned Users</a> appeared first on <a href="https://www.lavatelli.it">IT Blog Site</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Object Caching 75/92 objects using Redis
Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Minified using Redis

Served from: www.lavatelli.it @ 2026-11-21 08:55:43 by W3 Total Cache
-->