A trigger is triggered only when it is added. The purpose is to limit the ip address to send a text message for three minutes. The Access frequency of this table is very high for a certain period of time, the deadlock occurred during the peak hours today may be caused by the failure to judge the user's cause. Now let's take a look at the user's judgment. The code is roughly as follows: ALTERtrigger [dbo]. [trg_drv_y
A trigger is triggered only when it is added. The purpose is to limit the ip address to send a text message for three minutes. The Access frequency of this table is very high for a certain period of time, the deadlock occurred during the peak hours today may be caused by the failure to judge the user's cause. Now let's take a look at the user's judgment. The code is roughly as follows: ALTER trigger [dbo]. [trg_drv_y
A trigger is triggered only when it is added. The purpose is to limit the ip address to send a text message for three minutes. The Access frequency of this table is very high for a certain period of time, and a deadlock occurs during the peak hours today.
This may be because the user has not been determined. Add the user's judgment and try again. The code is roughly as follows:
ALTER trigger [dbo]. [trg_drv_yzm_insert] on [dbo]. [drv_yzm] for insert
As
Begin
If (CURRENT_USER = 'testuser ')
Begin
Declare @ lastcreatet varchar (50)
Declare @ lastdate datetime
Declare @ id int, @ clientip varchar (15), @ type varchar (20)
Select @ id = id, @ clientip = clientip, @ type = type from inserted;
Select top 1 @ lastcreatet = createt from drv_yzm where clientip = @ clientip and type = 'pre' and id <> @ id order by createt desc
Set @ lastdate = convert (datetime, substring (left (@ lastcreatet, 8) + ''+ substring (@ lastcreatet, 9,2) + ':' + substring (@ lastcreatet, 11,2) + ':' + substring (@ lastcreatet ))
Set @ lastdate = dateadd (mi, 3, @ lastdate)
If (@ lastdate> GETDATE () and @ type = 'pre ')
Update drv_yzm set status = '0' where id = @ id
End
End