How to debug a T-SQL trigger?

前端 未结 4 1540
清歌不尽
清歌不尽 2021-02-03 23:15

I have a table t, which has an \"after insert\" trigger called trgInsAfter. Exactly how do i debug it? i\'m no expert on this, so the question and steps performed might look sil

4条回答
  •  独厮守ぢ
    2021-02-03 23:30

    There is a DEBUG menu in SSMS, but you'll likely need to be on the server to be able to debug, so if it is a remote access, it's probably not gonna be set up for it. That debug option will allow you to execute code, and step into your trigger and debug it in that manner (as you'd debug most any other code).

    Debug menu

    If not having access to the debug menu/function, you'll have to debug "manually":

    First ensure your trigger is running correctly by inserting the input of the trigger into a debug table. Then you can verify that its called correctly. Then you can debug the query of the trigger as you would any other sql query, using the values from the debug table.

提交回复
热议问题