Handling multiple records in a MS SQL trigger

前端 未结 5 484
猫巷女王i
猫巷女王i 2020-12-13 16:43

I am having to use triggers in MSSQL for the first time, well triggers in general. Having read around and tested this myself I realise now that a trigger fires per command a

5条回答
  •  长情又很酷
    2020-12-13 17:20

    Depending on what version of MSSQL you are running, you should also consider using Indexed Views for this as well. That could very well be a simpler approach than your triggers, depending on what the report query looks like. See here for more info.

    Also, in your trigger, you should try to write your updates to the materialized results table as a set based operation, not a cursor. Writing a cursor based trigger could potentially just be moving your problem from the report query to your table inserts instead.

提交回复
热议问题