wenji643 于 2015.05.29 11:35 提问

ALTER TRIGGER [dbo].[INSERT_RECORD1_31128020]
ON [dbo].[ST_ZLZB_R]
AFTER INSERT
AS
BEGIN
IF EXISTS(SELECT * FROM INSERTED WHERE ((STCD ='31128020') or(STCD ='31128010') )and ( DRP>24.5 ))
INSERT INTO ST_ZLZB_R SELECT '31128020',TM,0,INTV,PDR,DYP,WTH FROM INSERTED where STCD ='31128020'
INSERT INTO ST_ZLZB_R SELECT '31128010',TM,0,INTV,PDR,DYP,WTH FROM INSERTED where STCD ='31128010'
END

3个回答

gamefinity   2015.05.29 13:57

``````ALTER TRIGGER [dbo].[INSERT_RECORD1_31128020]
ON [dbo].[ST_ZLZB_R]
AS
BEGIN
IF EXISTS(SELECT * FROM INSERTED WHERE ((STCD ='31128020') or(STCD ='31128010') )and ( DRP>24.5 ))
INSERT INTO ST_ZLZB_R
SELECT '31128020',
TM,
CASE WHEN (STCD ='31128020') or (STCD = '31128010') )and ( DRP>24.5 ) THEN 0 ELSE DRP END,
INTV,
PDR,
DYP,
WTH
FROM INSERTED
END
``````
qq_28398447   2015.05.29 12:41

testcs_dn   2015.05.29 13:30

BEGIN
IF EXISTS(SELECT * FROM INSERTED WHERE ((STCD ='31128020') or(STCD ='31128010') )and ( DRP>24.5 ))
INSERT INTO ST_ZLZB_R SELECT '31128020',TM,0,INTV,PDR,DYP,WTH FROM INSERTED where STCD ='31128020'
INSERT INTO ST_ZLZB_R SELECT '31128010',TM,0,INTV,PDR,DYP,WTH FROM INSERTED where STCD ='31128010'
END