我是MS SQL Server的新手。我知道基础知识,并且可以执行基本的表操作。今天我碰到了点东西。我正在尝试清除一些过时的信息表,并得到奇怪的消息和结果。
想象3-5个表,其中所有表都包含一个称为dteCreated的字段,该字段跟踪创建的条目日期/时间。我可以对此进行查询并选择以下行:
bcrypt.hash('salam', 10, (err, hash) => {
const akbar = hash;
bcrypt.compare('salam', akbar, (err, isMatch) => {
console.log(isMatch);
});
});
我想要记录超过90天的记录
我运行此查询,看到11,000条记录。
现在我尝试删除记录:
Select strHostname, dteCreated
From tblComputerProducts
Where (dteCreated < GetDate() - 90)
返回的结果类似于11000条记录。 我再次运行选择查询,但实际上什么都没有删除。
这是怎么回事,我该如何解决?
答案 0 :(得分:0)
you said that you were a novice, so you may need to understand that when you do an INSERT, UPDATE or DELETE command on a table, there is the possibility of trigger(s) being invoked.
The one you mention in the comments (shown below) is an INSTEAD OF trigger. It basically says, in this case that when a DELETE is executed against the table, don't do the DELETE, just run this trigger instead.
Normally a trigger will do some checking and/or some synchronisation and/or some logging and then actually do the DELETE of the records. In this case all it does is SET NOCOUNT ON, which is nothing. In other words the trigger is there to stop records from being deleted. It would have been nice if the author left a comment as to why.
This might be for historical, auditing or referential integrity reasons. Obviously this is not a database you have created yourself, so I am a little concerned that you have done something that the original creator tried to prevent. You may want to double check to make sure that there are no references to the dbo.ComputerProduct data that are now orphaned.
You said that the trigger was disabled. It's odd that it seemed not to be disabled. Odd...
Cheers
USE [WOL]
GO SET ANSI_NULLS ON
GO SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[CompProdDelete]
on [dbo].[ComputerProduct]
instead of Delete
AS
BEGIN
SET NOCOUNT ON;
END