SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


stored procedure


stored procedure

Author
Message
harriet.louis
harriet.louis
SSC-Addicted
SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)SSC-Addicted (431 reputation)

Group: General Forum Members
Points: 431 Visits: 109
how to check if a stored procedure is currently running - can anyone plz help with a solution?
Ramesh Saive
Ramesh Saive
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10222 Visits: 2643
Double post, continue discussions here

--Ramesh


arun.sas
arun.sas
SSCarpal Tunnel
SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)

Group: General Forum Members
Points: 4551 Visits: 3493
Hi,

try this sp

create procedure Spinrun (@Parameter varchar(90))
as
begin

create table #temp
(
eventtype nvarchar(30),
Parameters int,
EventInfo nvarchar(255)
)

declare @SPID varchar(10)
DECLARE OPENTRANS CURSOR FOR
SELECT SPID from master.dbo.sysprocesses (nolock)
OPEN OPENTRANS
FETCH NEXT FROM OPENTRANS into @SPID
WHILE @@FETCH_STATUS = 0
BEGIN

declare @SQL nvarchar(100)
set @SQL = N'dbcc inputbuffer ('+@SPID+')'
insert into #temp exec (@SQL)

FETCH NEXT FROM OPENTRANS into @SPID
END
CLOSE OPENTRANS
DEALLOCATE OPENTRANS


declare @Parameter varchar(100)
select @Parameter = ('%'+@Parameter+'%')
if exists (select 1 from #temp where eventinfo like @Parameter)
print 'SP is Running'
else
print 'SP is not Running'

end

-----
exec Spinrun 'SP NAME'
-----


ARUN SAS
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search