<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Cursor to Kill All Process in Database</title>
	<atom:link href="http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: SQL SERVER - Quickest Way to - Kill All Threads - Kill All User Session - Kill All Processes Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-46447</link>
		<dc:creator>SQL SERVER - Quickest Way to - Kill All Threads - Kill All User Session - Kill All Processes Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Sun, 08 Feb 2009 11:23:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-46447</guid>
		<description>[...] Read here for older method of using cursor - SQL SERVER - Cursor to Kill All Process in Database. [...]</description>
		<content:encoded><![CDATA[<p>[...] Read here for older method of using cursor &#8211; SQL SERVER &#8211; Cursor to Kill All Process in Database. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted A</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-34463</link>
		<dc:creator>Ted A</dc:creator>
		<pubDate>Wed, 19 Mar 2008 20:52:59 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-34463</guid>
		<description>Follow up to my previous comment. It looks like the &#039;&#039; were removed. My apologies to Viren since I believe he did the same thing.</description>
		<content:encoded><![CDATA[<p>Follow up to my previous comment. It looks like the &#8221; were removed. My apologies to Viren since I believe he did the same thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted A</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-34462</link>
		<dc:creator>Ted A</dc:creator>
		<pubDate>Wed, 19 Mar 2008 20:51:47 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-34462</guid>
		<description>Outstanding thread. This was really helpful in building a process for our system.  I really enjoyed the feedback with the multiple solutions.  

Viren, the select statement is invalid. 

I believe it should read.. 

select * from master.dbo.sysprocesses
where DB_NAME(dbid) = &#039;Lutheran&#039;
  and spid &gt; 50 and spid  @@SPID

Thanks all.</description>
		<content:encoded><![CDATA[<p>Outstanding thread. This was really helpful in building a process for our system.  I really enjoyed the feedback with the multiple solutions.  </p>
<p>Viren, the select statement is invalid. </p>
<p>I believe it should read.. </p>
<p>select * from master.dbo.sysprocesses<br />
where DB_NAME(dbid) = &#8216;Lutheran&#8217;<br />
  and spid &gt; 50 and spid  @@SPID</p>
<p>Thanks all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-33231</link>
		<dc:creator>John</dc:creator>
		<pubDate>Wed, 23 Jan 2008 21:44:50 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-33231</guid>
		<description>I never use cursors for loops. Just prefer to stay away from them. Here&#039;s my solution:

create proc msp_killallspids (@db varchar(255))as
declare @min int, @max int 
declare @dbname varchar(255), @dbid int 
declare @cmd varchar(255)


select @dbid = dbid from master..sysdatabases
where name = @db

select @min = min(spid) from master..sysprocesses where dbid = @dbid
select @max = max(spid) from master..sysprocesses where dbid = @dbid

while @min  @min
end</description>
		<content:encoded><![CDATA[<p>I never use cursors for loops. Just prefer to stay away from them. Here&#8217;s my solution:</p>
<p>create proc msp_killallspids (@db varchar(255))as<br />
declare @min int, @max int<br />
declare @dbname varchar(255), @dbid int<br />
declare @cmd varchar(255)</p>
<p>select @dbid = dbid from master..sysdatabases<br />
where name = @db</p>
<p>select @min = min(spid) from master..sysprocesses where dbid = @dbid<br />
select @max = max(spid) from master..sysprocesses where dbid = @dbid</p>
<p>while @min  @min<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: viren</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-24650</link>
		<dc:creator>viren</dc:creator>
		<pubDate>Thu, 06 Dec 2007 19:04:06 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-24650</guid>
		<description>Let me try again

&quot;
select @@spid
DECLARE @sql VARCHAR(500)
SET @sql = &#039;&#039;
SELECT @sql = @sql + &#039; KILL &#039; + CAST(spid AS VARCHAR(4)) + &#039; &#039;
FROM master.dbo.sysprocesses
WHERE DB_NAME(dbid) = &#039;Lutheran&#039;
AND spid &gt; 50 AND spid  @@SPID
select @sql
EXEC(@sql)

&quot;</description>
		<content:encoded><![CDATA[<p>Let me try again</p>
<p>&#8221;<br />
select @@spid<br />
DECLARE @sql VARCHAR(500)<br />
SET @sql = &#8221;<br />
SELECT @sql = @sql + &#8216; KILL &#8216; + CAST(spid AS VARCHAR(4)) + &#8216; &#8216;<br />
FROM master.dbo.sysprocesses<br />
WHERE DB_NAME(dbid) = &#8216;Lutheran&#8217;<br />
AND spid &gt; 50 AND spid  @@SPID<br />
select @sql<br />
EXEC(@sql)</p>
<p>&#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benjamin</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-10127</link>
		<dc:creator>Benjamin</dc:creator>
		<pubDate>Wed, 29 Aug 2007 16:05:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-10127</guid>
		<description>It helped!

Thanx!</description>
		<content:encoded><![CDATA[<p>It helped!</p>
<p>Thanx!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siddharth</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-6876</link>
		<dc:creator>Siddharth</dc:creator>
		<pubDate>Mon, 06 Aug 2007 10:21:29 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-6876</guid>
		<description>Nice article it help me alot</description>
		<content:encoded><![CDATA[<p>Nice article it help me alot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fastian</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-4608</link>
		<dc:creator>fastian</dc:creator>
		<pubDate>Wed, 11 Jul 2007 09:04:34 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-4608</guid>
		<description>For SQL server 2005:

CREATE TABLE #TmpWho
(spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150),
hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150), request_id INT)



request_id INT was missing...</description>
		<content:encoded><![CDATA[<p>For SQL server 2005:</p>
<p>CREATE TABLE #TmpWho<br />
(spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150),<br />
hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150), request_id INT)</p>
<p>request_id INT was missing&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nandkishor</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-2631</link>
		<dc:creator>Nandkishor</dc:creator>
		<pubDate>Sun, 27 May 2007 08:49:55 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-2631</guid>
		<description>There is no need to create the cursor to kill all the process on the sql server.
Instead we call compose a string like this

declare @SQLString varchar(8000)
set @SQLString = &#039;Kill 51;Kill 52;kill 53&#039;
exec (@SQLString)


which eleminate the need for cursor.

But we should check that the lengh of the string should be less than 8000.

that we can afford comared to Cursor.

Enjoy SQL</description>
		<content:encoded><![CDATA[<p>There is no need to create the cursor to kill all the process on the sql server.<br />
Instead we call compose a string like this</p>
<p>declare @SQLString varchar(8000)<br />
set @SQLString = &#8216;Kill 51;Kill 52;kill 53&#8242;<br />
exec (@SQLString)</p>
<p>which eleminate the need for cursor.</p>
<p>But we should check that the lengh of the string should be less than 8000.</p>
<p>that we can afford comared to Cursor.</p>
<p>Enjoy SQL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-2413</link>
		<dc:creator>pinaldave</dc:creator>
		<pubDate>Fri, 18 May 2007 15:51:24 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-2413</guid>
		<description>Thanks Ruslan your suggestion is implemented.
Regards,
Pinal Dave
(http://www.SQLAuthority.com)</description>
		<content:encoded><![CDATA[<p>Thanks Ruslan your suggestion is implemented.<br />
Regards,<br />
Pinal Dave<br />
(<a href="http://www.SQLAuthority.com" rel="nofollow">http://www.SQLAuthority.com</a>)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruslan</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-2409</link>
		<dc:creator>Ruslan</dc:creator>
		<pubDate>Fri, 18 May 2007 15:29:15 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-2409</guid>
		<description>--is not valid code
BEGIN
SET @tString = &#039;KILL &#039; + @spid
EXEC(@tString)
FETCH NEXT FROM @getspid INTO @spid
END

-- change
BEGIN
SET @tString = &#039;KILL &#039; + Cast(@spid as varchar)
EXEC(@tString)
FETCH NEXT FROM @getspid INTO @spid
END</description>
		<content:encoded><![CDATA[<p>&#8211;is not valid code<br />
BEGIN<br />
SET @tString = &#8216;KILL &#8216; + @spid<br />
EXEC(@tString)<br />
FETCH NEXT FROM @getspid INTO @spid<br />
END</p>
<p>&#8211; change<br />
BEGIN<br />
SET @tString = &#8216;KILL &#8216; + Cast(@spid as varchar)<br />
EXEC(@tString)<br />
FETCH NEXT FROM @getspid INTO @spid<br />
END</p>
]]></content:encoded>
	</item>
</channel>
</rss>
