﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Rafal S.  / Kill all connection to database / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 12:56:53 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Kill all connection to database</title><link>http://www.sqlservercentral.com/Forums/Topic1070958-1184-1.aspx</link><description>--Kill all users instantlyuse mastergoalter database test set offline with rollback immediategoalter database test set onlinego</description><pubDate>Thu, 19 May 2011 06:54:42 GMT</pubDate><dc:creator>Oliver Wootton</dc:creator></item><item><title>RE: Kill all connection to database</title><link>http://www.sqlservercentral.com/Forums/Topic1070958-1184-1.aspx</link><description>i use this:[code="sql"]ALTER DATABASE Northwind SET SINGLE_USER WITH ROLLBACK IMMEDIATEEXEC sp_dboption 'Northwind', 'single user', 'FALSE'[/code]</description><pubDate>Tue, 08 Mar 2011 00:49:11 GMT</pubDate><dc:creator>rktn_odin</dc:creator></item><item><title>RE: Kill all connection to database</title><link>http://www.sqlservercentral.com/Forums/Topic1070958-1184-1.aspx</link><description>You're right - this procedure would be much more simple if I used cursors as You did.</description><pubDate>Tue, 01 Mar 2011 07:37:26 GMT</pubDate><dc:creator>skra</dc:creator></item><item><title>RE: Kill all connection to database</title><link>http://www.sqlservercentral.com/Forums/Topic1070958-1184-1.aspx</link><description>i often use something more simple[code="sql"]DECLARE @TARGET INTWHILE 1=1BEGIN	DECLARE KILLCONS CURSOR LOCAL FAST_FORWARD FOR		SELECT SPID FROM MASTER..SYSPROCESSES WHERE DBID = DB_ID('DB NAME') AND SPID &amp;gt;=50	OPEN KILLCONS	FETCH NEXT FROM KILLCONS INTO @TARGET	WHILE @@FETCH_STATUS = 0	BEGIN		EXEC ('KILL '+@TARGET)		FETCH NEXT FROM KILLCONS INTO @TARGET	END	CLOSE KILLCONS	DEALLOCATE KILLCONSEND[/code]the infinite while is to take care of pesky applications that keep reconnecting, so you just manually break the loop when you feel like it</description><pubDate>Tue, 01 Mar 2011 07:10:17 GMT</pubDate><dc:creator>dant12</dc:creator></item><item><title>Kill all connection to database</title><link>http://www.sqlservercentral.com/Forums/Topic1070958-1184-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/SQL+Server+2005/72535/"&gt;Kill all connection to database&lt;/A&gt;[/B]</description><pubDate>Mon, 28 Feb 2011 20:37:42 GMT</pubDate><dc:creator>skra</dc:creator></item></channel></rss>