我在表上创建了一个触发器,现在我无法更改或删除它。 我甚至无法访问该表。 我该怎么办?
触发脚本:
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
答案 0 :(得分:2)
由于它抱怨无法获得锁定,这意味着某些进程专门保留了该表。您应该尝试重新启动服务器,然后发出drop trigger命令。
drop trigger [Products].[InsertLessThen5InStock]