Home > database >  Used to trigger 2017 created is not successful
Used to trigger 2017 created is not successful

Time:01-30

Below is I eat create a used to trigger logic, I succeed in navicat implementation is to create, but I found when testing to insert data into T_2 trigger logic is not effective, just I
Using the search triggers SQL
 select * from sysobjects where type='TR' 
, also can't search my create triggers, which eldest brother can help me have a look at this create a trigger statement if you have any questions?
 CREATE TRIGGER ins_tom_to_goods ON T_2 AFTER INSERT as 
The BEGIN
Declare @ CNT int.
Declare @ SQH varchar (30);
Declare @ ZLLX varchar (30);
Declare @ MSG varchar (255);
Declare @ qq varchar (50);
Declare @ phone varchar (50);
Declare @ ptime varchar (255);
The set @ SQH=(SELECT F_2 FROM Inserted).
The set @ CNT=(select COUNT (1) the from T_4 where F_20=@ SQH);
The set @ ZLLX=(SELECT F_7 FROM Inserted).
The set @ MSG=(SELECT F_9 FROM Inserted).
The set @ qq=(SELECT F_3 FROM Inserted).
The set @ phone=(SELECT F_5 FROM Inserted).
The set @ ptime=(SELECT F_6 FROM Inserted).

If @ CNT=0?
INSERT INTO T_4 (
ID,
CUID CDID, CUNAME,
CDATE F_20, F_22 F_24,
F_25 F_26, F_27
)
VALUES
(newId (), '1', '1', 'automatic insertion,
GETDATE (), @ SQH @ ZLLX, @ MSG,
@ qq, @ phone, @ ptime
);

End

CodePudding user response:

Did you create in the correct database?

CodePudding user response:

Big probability is not create success,


The create statement, performs twice in navicat, see what was the second prompt,
  • Related