RE: kill blocking processes - follow-up question

RE: kill blocking processes - follow-up question

 

  

Andrea;

Chip's suggestion works like a charm.

Xp_smtp_sendmail needs a string already assembled as the message, i.e.
"@message = @string1 + @string2" won't work, but if you do this, you can
add the output to your previously defined string:

create table #temp(event varchar(30),
parameters int,
Info varchar(255));

Declare @exec varchar(64)

Select @exec = 'dbcc inputbuffer(' + convert(varchar(6), <spid>) + ')'

insert into #temp
exec (@exec);

select @emailmessage =
@emailmessage
+ event
+ convert(varchar(16),parameters)
+ coalesce([Info],'')
from #temp


--Original Message--
Using xp_smtp_sendmail (see below) -- the message portion is just made
up
of text strings, which have been gathered from the SP. So I'm thinking
maybe all I need to do is get the output of DBCC INPUTBUFFER into a text

string, but I don't know if that is right, or how to do it. Sorry, I'm
a
newbie!



set @emailmessage = 'Process ' + @sql + ' has been killed ' + @kill_flag


exec master.dbo.xp_smtp_sendmail
@FROM = @emailSender,
@TO = @emailTo,
@subject = "Process Notification",
@message = @emailmessage,
@type = N'text/plain',
@server = @smtpServer


MS Sql Server LazyDBA home page