Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

Detecting Changes to a Table Expand / Collapse
Author
Message
Posted Sunday, May 22, 2011 9:52 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 3:34 AM
Points: 60, Visits: 292
Comments posted to this topic are about the item Detecting Changes to a Table
Post #1113012
Posted Monday, May 23, 2011 3:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 24, 2011 11:22 PM
Points: 2, Visits: 11
In this MSDN article there is information about what I understand is an "native" way of doing change tracking in relation to building applications for Sync Framework in SQL Server 2008, it that the CHECKSUM(), BINARY_CHECKSUM(), and CHECKSUM_AGG() functions mentioned in the article or is it a third way?

How to: Use SQL Server Change Tracking http://msdn.microsoft.com/en-us/library/cc305322.aspx
Post #1113214
Posted Monday, May 23, 2011 4:55 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 3:34 AM
Points: 60, Visits: 292
Hi jongy,

I'm afraid I am not very familiar with change tracking.

I also skim read the article you listed, but can see no mention of the CHECKSUM functions discussed in this article.

Regards,

Lawrence
Post #1113257
Posted Monday, May 23, 2011 4:59 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 24, 2011 11:22 PM
Points: 2, Visits: 11
Lawrence,

But do you then agree that the MSDN article outlines a third method for change tracking additional to the ones discussed in the SQL Central article or am I missunderstanding anything here?

/jongy
Post #1113262
Posted Monday, May 23, 2011 5:09 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 3:34 AM
Points: 60, Visits: 292
Agreed. I believe that the change tracking functionality is designed primarily to act at a lower level of granularity, so that individual row changes to a table can be audited, but I imagine you could also use it to provide an aggregated, summary "table level" view to judge if any changes have been performed across the whole table.

Thanks for pointing this out.

Regards,

Lawrence
Post #1113270
Posted Monday, May 23, 2011 6:29 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, January 25, 2014 7:57 AM
Points: 4, Visits: 54
What if you add a column UPDATED_ON of type datetime with default to GETDATE() ?
I suppose that it would make it work.
Post #1113284
Posted Monday, May 23, 2011 6:30 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 3:34 AM
Points: 60, Visits: 292
Hi fmendes,

That would cover inserted rows only, but not cater for updates on the row, nor row deletions.

Regards,

Lawrence.
Post #1113286
Posted Monday, May 23, 2011 7:45 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 3:26 PM
Points: 1,675, Visits: 4,779
SQL Server maintains statistics, which includes counts and timestamps, whenever table indexes are updated. This meta data can be queried from an interesting data management view called sys.dm_db_index_usage_stats. For some situations this would suit the purpose of detecting table changes.

For example:
select object_name(s.object_id) as table_name, i.name as index_name,
last_user_update, user_updates
from sys.dm_db_index_usage_stats as s
join sys.indexes i on i.object_id = s.object_id and i.index_id = s.index_id
where object_name(s.object_id) = 'InvHeader';

table_name index_name        last_user_update        user_updates
---------- ----------------- ----------------------- ------------
InvHeader pk_invheader 2011-05-20 15:50:07.210 3713
InvHeader uix_invheader 2011-05-19 19:15:01.370 371

There are other columns in this view that return the number of seeks, scans, etc. so it can also be levereaged to determine how often indexes or tables are being accessed.
Post #1113324
Posted Monday, May 23, 2011 8:06 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Today @ 3:34 AM
Points: 60, Visits: 292
Hi Eric,

Many thanks for your post.

It is true that DMVs offer lots of useful information, some of which could be applied for requirements discussed in my article.

However, DMVs typically require elevated user permissions, such as VIEW SERVER STATE.

Regards,

Lawrence
Post #1113336
Posted Monday, May 23, 2011 8:13 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, January 25, 2014 7:57 AM
Points: 4, Visits: 54
Thanks! You're correct.

I should have thought of timestamp/rowversion instead of datetime.
Post #1113340
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse