<?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>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 24 May 2013 22:47:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER – Find Stored Procedure and View Related to Table in Database – Search in All Stored Procedure &#171; inforakesha</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-406333</link>
		<dc:creator><![CDATA[SQL SERVER – Find Stored Procedure and View Related to Table in Database – Search in All Stored Procedure &#171; inforakesha]]></dc:creator>
		<pubDate>Fri, 11 Jan 2013 06:12:23 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-406333</guid>
		<description><![CDATA[[...] « SQL SERVER – Cursor to Kill All Process in Database SQL SERVER – Fix : Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved. » [...]]]></description>
		<content:encoded><![CDATA[<p>[...] « SQL SERVER – Cursor to Kill All Process in Database SQL SERVER – Fix : Error 14274: Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server. The job was not saved. » [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #005 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-384374</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #005 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 01 Dec 2012 01:30:38 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-384374</guid>
		<description><![CDATA[[...] SQL SERVER – Cursor to Kill All Process in Database I indeed wrote this cursor and when I often look back, I wonder how naive I was to write this. The reason for writing this cursor was to free up my database from any existing connection so I can do database operation. This worked fine but there can be a potentially big issue if there was any important transaction was killed by this process. There is another way to to achieve the same thing where we can use ALTER syntax to take database in single user mode. Read more about that over here and here. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER – Cursor to Kill All Process in Database I indeed wrote this cursor and when I often look back, I wonder how naive I was to write this. The reason for writing this cursor was to free up my database from any existing connection so I can do database operation. This worked fine but there can be a potentially big issue if there was any important transaction was killed by this process. There is another way to to achieve the same thing where we can use ALTER syntax to take database in single user mode. Read more about that over here and here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arkadiy</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-352355</link>
		<dc:creator><![CDATA[Arkadiy]]></dc:creator>
		<pubDate>Sun, 23 Sep 2012 18:49:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-352355</guid>
		<description><![CDATA[Another &quot;no cursor&quot; approach:

use master
go

declare @dbname1 varchar(255)
set @dbname1=&#039;YourDatabase&#039;
while (select COUNT(spid)  from master..sysprocesses where dbid=db_id(@dbname1))&gt;0
begin
declare @klpr1 nvarchar(30)
;with proc1 as ( select top 1 &#039;Kill &#039; + convert(nvarchar(30),spid) as KlPr from master..sysprocesses where dbid=
db_id(@dbname1) order by db_id(@dbname1))
select  @klpr1=(select  KlPr from proc1)

exec(@klpr1)
WAITFOR delay &#039;00:00:01&#039;
print @klpr1
end

You can comment out &quot;print ...&quot; (it just prints the process number) and 
&quot;WAITFOR delay &#039;00:00:01&#039;&quot; - it just gives time to kill a process without looping through the same one]]></description>
		<content:encoded><![CDATA[<p>Another &#8220;no cursor&#8221; approach:</p>
<p>use master<br />
go</p>
<p>declare @dbname1 varchar(255)<br />
set @dbname1=&#8217;YourDatabase&#8217;<br />
while (select COUNT(spid)  from master..sysprocesses where dbid=db_id(@dbname1))&gt;0<br />
begin<br />
declare @klpr1 nvarchar(30)<br />
;with proc1 as ( select top 1 &#8216;Kill &#8216; + convert(nvarchar(30),spid) as KlPr from master..sysprocesses where dbid=<br />
db_id(@dbname1) order by db_id(@dbname1))<br />
select  @klpr1=(select  KlPr from proc1)</p>
<p>exec(@klpr1)<br />
WAITFOR delay &#8217;00:00:01&#8242;<br />
print @klpr1<br />
end</p>
<p>You can comment out &#8220;print &#8230;&#8221; (it just prints the process number) and<br />
&#8220;WAITFOR delay &#8217;00:00:01&#8242;&#8221; &#8211; it just gives time to kill a process without looping through the same one</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Using RANKING Functions Instead of SQL Looping Logic of Cursor &#8211; Quiz &#8211; Puzzle &#8211; 8 of 31 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-233871</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Using RANKING Functions Instead of SQL Looping Logic of Cursor &#8211; Quiz &#8211; Puzzle &#8211; 8 of 31 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Mon, 09 Jan 2012 01:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-233871</guid>
		<description><![CDATA[[...] SQL Server Interview Questions and Answers ISBN: 1466405643 Page#128-129  Use INSERT INTO … SELECT instead of Cursor  Simple Use of Cursor to Print All Stored Procedures of Database  Simple Use of Cursor to Print All Stored Procedures of Database Including Schema  Simple Example of Cursor  Cursor to Kill All Process in Database [...]]]></description>
		<content:encoded><![CDATA[<p>[...] SQL Server Interview Questions and Answers ISBN: 1466405643 Page#128-129  Use INSERT INTO … SELECT instead of Cursor  Simple Use of Cursor to Print All Stored Procedures of Database  Simple Use of Cursor to Print All Stored Procedures of Database Including Schema  Simple Example of Cursor  Cursor to Kill All Process in Database [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anupam Awasthi</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-73513</link>
		<dc:creator><![CDATA[Anupam Awasthi]]></dc:creator>
		<pubDate>Thu, 27 May 2010 15:50:57 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-73513</guid>
		<description><![CDATA[Chhavi,
You can take Database Offline or Detached Database by doing following Stapes. 
Select Database-&gt;Right Click on Databae-&gt;Task-&gt;Detach
Select Database-&gt;Right Click on Databae-&gt;Task-&gt;Take Offline]]></description>
		<content:encoded><![CDATA[<p>Chhavi,<br />
You can take Database Offline or Detached Database by doing following Stapes.<br />
Select Database-&gt;Right Click on Databae-&gt;Task-&gt;Detach<br />
Select Database-&gt;Right Click on Databae-&gt;Task-&gt;Take Offline</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chhavi</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-72276</link>
		<dc:creator><![CDATA[Chhavi]]></dc:creator>
		<pubDate>Sat, 22 May 2010 09:32:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-72276</guid>
		<description><![CDATA[Hi All,

How can we physically shutdown the SQL Server 2005 database(Not SQL Server).

I don&#039;t want to use offlline option...

I&#039;ll really appreciate any kind of help!!!!!!!

Many Thanks,
Chhavi]]></description>
		<content:encoded><![CDATA[<p>Hi All,</p>
<p>How can we physically shutdown the SQL Server 2005 database(Not SQL Server).</p>
<p>I don&#8217;t want to use offlline option&#8230;</p>
<p>I&#8217;ll really appreciate any kind of help!!!!!!!</p>
<p>Many Thanks,<br />
Chhavi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhijit</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-61626</link>
		<dc:creator><![CDATA[Abhijit]]></dc:creator>
		<pubDate>Tue, 23 Feb 2010 07:51:16 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-61626</guid>
		<description><![CDATA[There are different option to KILL all the process in the current databases one is listed above by Pinal and the second is

ALTER DATABASE mydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

ALTER DATABASE mydb SET MULTI_USER
GO]]></description>
		<content:encoded><![CDATA[<p>There are different option to KILL all the process in the current databases one is listed above by Pinal and the second is</p>
<p>ALTER DATABASE mydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE<br />
GO</p>
<p>ALTER DATABASE mydb SET MULTI_USER<br />
GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ANUPAM</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-61236</link>
		<dc:creator><![CDATA[ANUPAM]]></dc:creator>
		<pubDate>Tue, 16 Feb 2010 11:16:17 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-61236</guid>
		<description><![CDATA[Pinal,
As I know we should avid the use of Cursors as much as possible, hence this task also be done with the help of Identity Column in Tem Table. Microsoft also does not recommend using Cursors because it make Round trip to the server for every record fetch. This task also can be done through following Code.

----------------------------------------------------------------------
DECLARE @count INT ,
		@sno INT	,
		@tString VARCHAR(50)

SET @sno=1

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)

INSERT INTO #TmpWho
EXEC sp_who


CREATE TABLE #TmpWho_second
(sno INT IDENTITY, spid INT, ecid INT, status VARCHAR(150), loginame VARCHAR(150),
hostname VARCHAR(150), blk INT, dbname VARCHAR(150), cmd VARCHAR(150),Request_id INT)

SELECT @count=count(*) from #TmpWho_second 
INSERT INTo #TmpWho_second
SELECT spid,ecid,status,loginame,hostname,blk,dbname,cmd,Request_id FROM #TmpWho WHERE spid&gt;50

WHILE @sno&lt;=@count
BEGIN
	SELECT @tString=&#039;kill &#039;+cast(spid as VARCHAR(5)) FROM #TmpWho_second WHERE sno=@sno
	EXEC (@tString)
	SELECT @sno AS sno
SET @sno=@sno+1
END

DROP TABLE #TmpWho
DROP TABLE #TmpWho_second
-----------------------------------------------------------------------]]></description>
		<content:encoded><![CDATA[<p>Pinal,<br />
As I know we should avid the use of Cursors as much as possible, hence this task also be done with the help of Identity Column in Tem Table. Microsoft also does not recommend using Cursors because it make Round trip to the server for every record fetch. This task also can be done through following Code.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
DECLARE @count INT ,<br />
		@sno INT	,<br />
		@tString VARCHAR(50)</p>
<p>SET @sno=1</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>INSERT INTO #TmpWho<br />
EXEC sp_who</p>
<p>CREATE TABLE #TmpWho_second<br />
(sno INT IDENTITY, 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>SELECT @count=count(*) from #TmpWho_second<br />
INSERT INTo #TmpWho_second<br />
SELECT spid,ecid,status,loginame,hostname,blk,dbname,cmd,Request_id FROM #TmpWho WHERE spid&gt;50</p>
<p>WHILE @sno&lt;=@count<br />
BEGIN<br />
	SELECT @tString=&#039;kill &#039;+cast(spid as VARCHAR(5)) FROM #TmpWho_second WHERE sno=@sno<br />
	EXEC (@tString)<br />
	SELECT @sno AS sno<br />
SET @sno=@sno+1<br />
END</p>
<p>DROP TABLE #TmpWho<br />
DROP TABLE #TmpWho_second<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2006/12/01/sql-server-cursor-to-kill-all-process-in-database/#comment-61159</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Mon, 15 Feb 2010 11:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-61159</guid>
		<description><![CDATA[You should always specify the length when converting data to VARCHAR. Because the default size may vary depnds on how you use

See more infomrations here

http://beyondrelational.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx]]></description>
		<content:encoded><![CDATA[<p>You should always specify the length when converting data to VARCHAR. Because the default size may vary depnds on how you use</p>
<p>See more infomrations here</p>
<p><a href="http://beyondrelational.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx</a></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-59219</link>
		<dc:creator><![CDATA[John]]></dc:creator>
		<pubDate>Thu, 31 Dec 2009 19:47:55 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/01/cursor-to-kill-all-process-in-database/#comment-59219</guid>
		<description><![CDATA[I know this articl was written well over 3 years ago but I had to add something to it to get it to work.  Probably a SP that came along &amp; updated the &quot;sp_who&quot; stored proc.

I had to add  &quot;request_id varchar(150)&quot; in the field list after the create table function.  Then it worked fine.
Reason being I kept getting a &quot;Insert Error: Column name or number of supplied values does not match table definition.&quot;

Thanks for all the easy to follow code, pinaldave!]]></description>
		<content:encoded><![CDATA[<p>I know this articl was written well over 3 years ago but I had to add something to it to get it to work.  Probably a SP that came along &amp; updated the &#8220;sp_who&#8221; stored proc.</p>
<p>I had to add  &#8220;request_id varchar(150)&#8221; in the field list after the create table function.  Then it worked fine.<br />
Reason being I kept getting a &#8220;Insert Error: Column name or number of supplied values does not match table definition.&#8221;</p>
<p>Thanks for all the easy to follow code, pinaldave!</p>
]]></content:encoded>
	</item>
	<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><![CDATA[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><![CDATA[[...] 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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[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><![CDATA[--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>
