-1

我在表上创建了一个触发器,现在我无法更改或删除它。我什至无法访问该表。我能做些什么?

触发脚本:

create  trigger [Products].[InsertLessThen5InStock]
on [Products].[Products]
after update
as
BEGIN
    DECLARE @ck int

            select UnitsInStock from Products.Products where UnitsInStock<5
    set @ck=@@ROWCOUNT
    print @ck
    if @ck >0
    BEGIN
        DECLARE @mails varchar (200)
        exec dbo.Manager_email @mails output
        EXEC msdb.dbo.sp_send_dbmail
        @profile_name =             'DefaultMailSender',
        @recipients =               @mails ,
        @body =                     'Products that will expire in less then 5 days',
        @subject =                  'Products that will expire in less then 5 days',
        @body_format =              'HTML',
        @query =                    'EXECUTE MadCat.dbo.SaveTableAsHTML 
                                @DBFetch =''select UnitsInStock from Products.Products where UnitsInStock<5'''

    END
END
GO
4

1 回答 1

2

由于它抱怨无法获得锁,这意味着某些进程已独占保留该表。您应该尝试重新启动服务器,然后发出 drop trigger 命令。

drop trigger [Products].[InsertLessThen5InStock]
于 2013-03-27T18:49:21.157 回答