How to find out when the scope of a Sql database changes?

One of the fields in my database in the table is being changed by some piece of code. I just can't figure out where!

So, I was wondering if there is a way to find out.

I am using SQL 2008. Can Profiler be used to find out if a particular field is being updated? How?

How about a trigger? If you use a trigger (e.g. UPDATE), can you determine which code named it? How can a trigger “notify me of this”? Email / file?

+3
source share
3 answers

Yes, the AFTER UPDATE trigger in this particular table and field can give you some clues as to when and why the field is changing.

From books on the Internet:

CREATE TRIGGER reminder
ON Person.Address
AFTER UPDATE 
AS 
  IF ( UPDATE (StateProvinceID) OR UPDATE (PostalCode) )
  BEGIN
    RAISERROR (50009, 16, 10)
  END;
GO

T-SQL - , , . - .

EDIT: , , , , , . , ( ).

+4

Yes, you can use a trigger to execute some code (keep track of who updates the table, email you, etc.) when the table is updated. See This Link: Track Updates Using a Database Trigger

Edit: Wrong link originally posted

0
source

Source: https://habr.com/ru/post/1709154/


All Articles