简体   繁体   中英

Track the user that changed/updated a row in database table - sql server

I need to make a column that whenever a user on the network updates the row through the listview in an ASP.net web page, it can find and store that in the column one that row. Does anybody have an example of this?

One way you could do this, is to use SQL Change Tracking. Take a look at MSDN SQL Change Tracking

Here is an excerpt to describe what the change tracking is capable of;

What rows have changed for a user table? Only the fact that a row has changed is required, not how many times the row has changed or the values of any intermediate changes. The latest data can be obtained directly from the table that is being tracked. Has a row changed?b The fact that a row has changed and information about the change must be available and recorded at the time that the change was made in the same transaction.

To enable this on SQL Server 2014 you need to run the following snippet;

ALTER DATABASE AdventureWorks2012
SET CHANGE_TRACKING = ON
(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM