March 3, 2004 at 5:37 am
Hi All,
I am trying to kill a process with a stored proc. The spID to be killed is passed into the StoredProc. I cannot get it to compile unless I remove the parameter and hardcode it (which is not what I want).
What am I doing wrong ?
Thanks
CCB
CREATE PROCEDURE [dbo].[prc004KillProcess]
(@intSPID smallint)
AS
Kill @intSPID
GO
March 3, 2004 at 6:23 am
sp_sqlexec() ???
I think you mean sp_executesql()
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
March 3, 2004 at 6:31 am
I guess that will not work....finally when it gets to executing the Kill statement it will throw an error saying the Kill "expects a handle (SPID) tinyint."
Correct me if i am wrong!
Cheers!
Arvind
March 3, 2004 at 6:41 am
This works fine, well you have to make it a varchar not a vaschar, but that's just semantics.
March 3, 2004 at 6:46 am
that was a typo. I was just trying to help. BTW is not semantics is syntaxis
* Noel
March 3, 2004 at 6:48 am
I have some cream that will take care of that
March 3, 2004 at 7:42 am
nope.. sorry
I ment sp_sqlexec
Look in the Master database under stored procedures.. you will find sp_sqlexec
there is how ever a stored procedure sp_executesql
The difference?? Well sp_executesql is an extended stored procedure
sp_sqlexec is not...
-- Procedure Script
create procedure sp_sqlexec --- 1996/04/08 00:00
@p1 text
as
exec(@p1)
--------------------
Well you can use either one.
March 3, 2004 at 7:57 am
Well, you shouldn't use sp_sqlexec any more as BOL states for SQL Server 2000
>Removed; no longer available. Remove all references to sp_sqlexec.
It can be found when searching for sq_sqlexec
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
July 6, 2004 at 3:45 pm
Very interesting topic!
The example above works fine if you have the SPID number.
There is a case when you need to kill an orphaned distributed transaction (SPID = -2) where in this case the KILL command will need the UOW instead of the process ID, i.e
KILL '9BE76755-54C9-4697-87BB-CD2D1F5648EC'
where 9BE76755-54C9-4697-87BB-CD2D1F5648EC is the UOW.
I trouble is that the KILL command would want the UOW to be between two apostrophes ('),
I tried this:
SET @command ='KILL ' + cast (@uow as varchar(50))
but it didn't work!
Any idea?
Dhafir
July 7, 2004 at 5:22 am
Try
SET @command ='KILL ''' + cast (@uow as varchar(50)) + ''''
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply