Check for changes to an SQL Server table?

前端 未结 8 1144
有刺的猬
有刺的猬 2020-12-04 08:02

How can I monitor an SQL Server database for changes to a table without using triggers or modifying the structure of the database in any way? My preferred programming enviro

8条回答
  •  时光说笑
    2020-12-04 08:29

    Take a look at the CHECKSUM command:

    SELECT CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM sample_table WITH (NOLOCK);
    

    That will return the same number each time it's run as long as the table contents haven't changed. See my post on this for more information:

    CHECKSUM

    Here's how I used it to rebuild cache dependencies when tables changed:
    ASP.NET 1.1 database cache dependency (without triggers)

提交回复
热议问题