2

I could not ALTER the trigger as its taking more then 80 min, and cannot delete/drop also , while trying to do this from Designer mode it shows erroe as

->Drop Failed for trigger. "LOCK request timeout period exceeded." enter image description here But the same trigger has been ALTER/DROP in other database containing same table.

  • I have changed the Table and Database Designers transaction timeout after to 30000 sec as suggested by some of the Forms.
  • And Uncheck Prevent saving changes that require table re-creation inside TOOLS->OPTION->DESIGNER. After running Activity monitor enter image description here

Is my trigger not ALTERING/DROPPING Due to this ? Or some other reasons?

enter image description here

2 Answers 2

9

Most probably there is another process with an open transaction on the table. To find what process has open transactions:

  1. DBCC OPENTRAN (Database)
  2. exec sp_who2
  3. from SSMS right click on the server name, select Activity Monitor. If you run it while you are trying to alter the trigger, you can look in the blocked by column.

then you need to end the spid that has the open transaction or worst case to kill spid

7
  • DBCC OPENTRAN [BumHy] Shows-Incorrect syntax near BumHy. And i could not find Activity Monitor on right clicking on database name.
    – Teju MB
    Sep 17, 2013 at 6:08
  • The transaction information is - Transaction information for database 'BumHY'. Replicated Transaction Information: Oldest distributed LSN : (0:0:0) Oldest non-distributed LSN : (3383:7572:1) DBCC execution completed. If DBCC printed error messages, contact your system administrator.
    – Teju MB
    Sep 17, 2013 at 6:16
  • Are you sure that you didn't find Activity Monitor when you right click on the ServerName? did you try EXEC sp_who2?
    – Luis LL
    Sep 17, 2013 at 6:19
  • I am really sorry, i was clicking on database name, anyhow i have uploaded the activity screen in my updated answer.
    – Teju MB
    Sep 17, 2013 at 6:24
  • 1
    - In step 2, Use execute sp_who2 'active' can help you filter the result for actived spid - Blocked By is blkBy column
    – Chinh Phan
    Apr 28, 2015 at 8:42
0
CREATE PROC er_kilitlenmecoz as
declare @max_count int, @count int, @sqlstring varchar(100)
declare @spid_table table (spid int NOT NULL)

INSERT @spid_table
select spid
from master.dbo.sysprocesses
where spid in (select blocked from master.dbo.sysprocesses where blocked <> 0) and blocked = 0

select @max_count = MAX(spid) FROM @spid_table
select top 1 @count = spid from @spid_table

while @count <= @max_count
begin
select @sqlstring = 'kill ' + CONVERT(varchar(4), @count)
exec(@sqlstring)
print @sqlstring

IF @count = @max_count
begin
break
end
ELSE
BEGIN
select top 1 @count = spid FROM @spid_table where spid > @count
end
end

--- RUN SCRİPT--DİSABLE TRİGGER

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.