sql - Trigger on multiple row result set -
i need create trigger notification low result on survey response , needs emailed.
a completed survey inserts along lines of:
results_recid question points 1800 rate our service 2 1800 recommend us? 3 1800 additional comments? 0 1800 <potential question 4> 1800 <potential question 5> 1800 <potential question 6>
the number of questions can vary depending on how survey set up.
retrieve latest set of results with:
select srd.points dbo.sv_resultsdtl srd (srd.sv_resultshdr_recid in (select max(srd.sv_resultshdr_recid sv_resultsdtl srd)) , (srd.points < 3)
the trigger fire each row below 3.
is there way fire once, include results <3 in notification, regardless of how many rows returned?
when comes sql server, triggers executed per statement not per row.it means that, if use:
insert tablename (columns...) values (val1, val2), (val1,val2)
then trigger execute once when statement finished.i think need.
one more thing, sure solution safe? assuming max value value of current survey.it might not case in circumstances.
select srd.points dbo.sv_resultsdtl srd (srd.sv_resultshdr_recid in (select max(srd.sv_resultshdr_recid sv_resultsdtl srd)) , (srd.points < 3)
regards
Comments
Post a Comment