SQL Server A trigger to work on multiple row inserts

后端 未结 3 1900
难免孤独
难免孤独 2020-12-01 13:35

I am maintaining some code that has a trigger on a table to increment a column. That column is then used by a 3rd party application A. Lets say that the table is ca

3条回答
  •  佛祖请我去吃肉
    2020-12-01 13:49

    Trigger needs to be rewriteen to handle multiple row inserts. Never write a trigger like that using variables. All triggers must alawys consider that someday someone is going to do a multi-row insert/update/delete.

    You shouldn't be incrementing columns that way in a trigger either, if you need incremented column numbers why aren't you using an identity column?

提交回复
热议问题