<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The Synchronizer : SqlChangeTracking</title><link>http://blogs.msdn.com/synchronizer/archive/tags/SqlChangeTracking/default.aspx</link><description>Tags: SqlChangeTracking</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Sync Designer in VS2008 SP1</title><link>http://blogs.msdn.com/synchronizer/archive/2008/05/30/sync-designer-in-vs2008-sp1.aspx</link><pubDate>Fri, 30 May 2008 23:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8564314</guid><dc:creator>Rafik</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/synchronizer/comments/8564314.aspx</comments><wfw:commentRss>http://blogs.msdn.com/synchronizer/commentrss.aspx?PostID=8564314</wfw:commentRss><description>
&lt;p&gt;I am sure you already know that SP1 Beta for Visual Studio 2008 is available to &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=CF99C752-1391-4BC3-BABC-86BC0B9E8E5A&amp;amp;displaylang=en" class="" mce_href="http://www.microsoft.com/downloads/details.aspx?familyid=CF99C752-1391-4BC3-BABC-86BC0B9E8E5A&amp;amp;displaylang=en"&gt;download&lt;/a&gt;. There are plenty of enhancements that I am sure the VS folks are covering all over the net with different blogs. As a sync guy, I am on the lookout for everything new in sync and SP1 has made a lot of improvement to the Sync Designer introduced for the first time with Visual Studio 2008.&lt;/p&gt;

&lt;p&gt;The designer was revamped quite a bit and it much more developer friendly now. The biggest improvement however is the ability to tap into SQL Server 2008 Change Tracking feature. The designer gives you the ability to use Change Tracking instead of the traditional trigger based model (a.k.a. coupled tracking as tracking columns are coupled with data columns in the base table).&amp;nbsp;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://blogs.msdn.com/synchronizer/attachment/8564314.ashx" style="width: 516px; height: 383px;" mce_src="http://blogs.msdn.com/synchronizer/attachment/8564314.ashx" width="516" align="middle" height="383"&gt;&lt;/p&gt;

&lt;p&gt;Under the covers, the Sync Designer uses a newer version of the SqlAdapterBuilder to generate the adapter that works against SQL Change Tracking. The new class is part of the newer beta bits of the Sync Services for ADO.NET. Developers can dynamically generate the commands be configuring the builder to run against an instance of SQL Server 2008 with Change Tracking enabled on the target table. &lt;/p&gt;

&lt;p&gt;Guy Burstein has written a &lt;a href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2008/05/12/sync-services-for-ado-net-with-sql-server-2008-change-tracking.aspx" class="" mce_href="http://blogs.microsoft.co.il/blogs/bursteg/archive/2008/05/12/sync-services-for-ado-net-with-sql-server-2008-change-tracking.aspx"&gt;really good post&lt;/a&gt; on the new changes in the sync designer with nice snapshots including the one I posted here. Make sure to check it out.&lt;/p&gt;

&lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing: 0px; font-family: Arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: normal; font-size-adjust: none; font-stretch: normal; text-transform: none; color: rgb(0, 0, 0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2;"&gt;Update: Just to let you know, I left Microsoft to start a new company, &lt;b&gt;&lt;a href="http://www.raveable.com" title="raveable hotel reviews" mce_href="http://www.raveable.com"&gt;Raveable Hotel Reviews.&lt;/a&gt;&lt;/b&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;See Examples:&amp;nbsp;&lt;b&gt;&lt;a href="http://www.raveable.com/sc/myrtle-beach/romantic-hotels-in-myrtle-beach/l6180c2" mce_href="http://www.raveable.com/sc/myrtle-beach/romantic-hotels-in-myrtle-beach/l6180c2"&gt;Romantic Hotels in Myrtle Beach&lt;/a&gt;&lt;/b&gt;, &lt;b&gt;&lt;a href="http://www.raveable.com/wa/seattle/top-10-hotels-in-seattle/l7344c3" mce_href="http://www.raveable.com/wa/seattle/top-10-hotels-in-seattle/l7344c3"&gt;Top 10 Hotels in Seattle&lt;/a&gt;&lt;/b&gt;, &lt;a href="http://www.raveable.com/fl/miami/best-hotels-in-miami/l1644c1" title="best hotels in miami" mce_href="http://www.raveable.com/fl/miami/best-hotels-in-miami/l1644c1"&gt;&lt;b&gt;Best Hotels in Miam&lt;/b&gt;i&lt;/a&gt;, &lt;b&gt;&lt;a href="http://www.raveable.com/ca/san-francisco/best-hotels-in-san-francisco/l717c1" title="best hotels in san francisco" mce_href="http://www.raveable.com/ca/san-francisco/best-hotels-in-san-francisco/l717c1"&gt;Best Hotels in San Francisco&lt;/a&gt;&lt;/b&gt;, &lt;b&gt;&lt;a href="http://www.raveable.com/hotels-with-jacuzzi" title="hotels with jacuzzi" mce_href="http://www.raveable.com/hotels-with-jacuzzi"&gt;Hotels with in-room jacuzzi&lt;/a&gt;&lt;/b&gt; and &lt;span class="Apple-converted-space"&gt;&lt;b&gt;&lt;a href="http://www.raveable.com/ca/los-angeles/5-star-hotels-in-los-angeles/l519c15" title="5 star hotels in los angeles" mce_href="http://www.raveable.com/ca/los-angeles/5-star-hotels-in-los-angeles/l519c15"&gt;5 Star Hotels in Los Angeles&lt;/a&gt;&lt;/b&gt;. Your feedback is welcome on &lt;a href="http://twitter.com/raveable" mce_href="http://twitter.com/raveable"&gt;twitter.com/raveable&lt;/a&gt;, &lt;a href="http://blog.raveable.com" title="raveable hotel reviews blog" mce_href="http://blog.raveable.com"&gt;raveable blog&lt;/a&gt;.&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-converted-space"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="word-spacing: 0px; font-family: Arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: normal; font-size-adjust: none; font-stretch: normal; text-transform: none; color: rgb(0, 0, 0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2;"&gt;I am not actively blogging about Sync Technologies. Please see &lt;a href="http://blogs.msdn.com/sync/" class="" mce_href="http://blogs.msdn.com/sync/"&gt;Sync Team Blog&lt;/a&gt; for more updated content.&amp;nbsp;&lt;/span&gt;&lt;br&gt;&lt;/p&gt;

&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8564314" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/synchronizer/attachment/8564314.ashx" length="23903" type="image/jpeg" /><category domain="http://blogs.msdn.com/synchronizer/archive/tags/SQL2008/default.aspx">SQL2008</category><category domain="http://blogs.msdn.com/synchronizer/archive/tags/SqlChangeTracking/default.aspx">SqlChangeTracking</category><category domain="http://blogs.msdn.com/synchronizer/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://blogs.msdn.com/synchronizer/archive/tags/SyncDesigner/default.aspx">SyncDesigner</category></item><item><title>SQL Server Change Tracking vs min_active_rowversion()</title><link>http://blogs.msdn.com/synchronizer/archive/2008/02/06/sql-server-change-tracking-vs-min-active-rowversion.aspx</link><pubDate>Wed, 06 Feb 2008 23:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7497291</guid><dc:creator>Rafik</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/synchronizer/comments/7497291.aspx</comments><wfw:commentRss>http://blogs.msdn.com/synchronizer/commentrss.aspx?PostID=7497291</wfw:commentRss><description>&lt;p&gt;In a bit &lt;a href="http://blogs.msdn.com/synchronizer/archive/2007/02/20/a-nice-gift-from-sql-server-2005-sp2-to-sync-developers.aspx" class="" mce_href="http://blogs.msdn.com/synchronizer/archive/2007/02/20/a-nice-gift-from-sql-server-2005-sp2-to-sync-developers.aspx"&gt;old post&lt;/a&gt; I wrote about min_active_rowversion() as the best way to get the new anchor showing you that @@DBTS has its flaws and thus should be avoided. Min_active_rowversion() was introduced in SP2 for SQL Server 2005. If you have code that still uses @@DBTS, you are running the risk of missing changes from the server, do yourself a favor and change it now.&lt;br&gt;&amp;nbsp;&lt;br&gt;Despite the a fact that min_active_rowversion() addressed a major problem for sync developers, it did not solve it. Check out the diagram below:&lt;/p&gt;&lt;p mce_keep="true"&gt;&lt;img src="http://blogs.msdn.com/synchronizer/attachment/7497291.ashx" title="Timestamp based versioning" style="width: 500px; height: 211px;" alt="Timestamp based versioning" mce_src="http://blogs.msdn.com/synchronizer/attachment/7497291.ashx" height="211" width="500"&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;T1 made a change to R1 row which received a timestamp of 50. The transaction did not commit and when you call min_active_rowversion() you will end up with the value of 50. That’s quite what we expect; sync should then synchronize up to 50-1 = 49 anchor. So what if we have few more transactions, like T2, that started after T1 and committed soon thereafter. If T1 did not commit, then min_active_rowversion() will remain at 50 until T1 commits. This could be a problem in many situations. You see, min_active_rowversion() did address the problem but did not solve it. Still much better that @@DBTS.&lt;br&gt;&amp;nbsp;&lt;br&gt;If we dig deeper into what the problem really is, we find that timestamp value is assigned at the statement execution time and not at transaction commit time. Had the row version be assigned at the transaction commit time, we would have a real solution for this problem. Fortunately, that’s exactly what SQL Server Change Tracking does for you in SQL Server 2008. Each transaction gets a version at the commit time and all the rows affected by the transaction will get that version. Check out the diagram below:&lt;/p&gt;&lt;p&gt;&lt;img src="http://blogs.msdn.com/synchronizer/attachment/7229879.ashx" title="SQL Change Tracking Versioning Scheme" style="width: 500px; height: 246px;" alt="SQL Change Tracking Versioning Scheme" mce_src="http://blogs.msdn.com/synchronizer/attachment/7229879.ashx" height="246" width="500"&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;SQL Change Tracking will assign version at transaction commit time and all the rows affected by the transaction will have the same version. Now, when you try to sync before T1 or T2 starts, you should get 49, whereas after T2 commits, you will receive a value of 50. You see, now you are not stuck waiting for that long transaction to commits to sync changes that happened in subsequent transactions. Pretty cool, huh! …&lt;/p&gt;&lt;p&gt;SQL Server Change Tracking is a reliable way to track changes and designed from the ground up to address the needs of data synchronization applications! &lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Tahoma; font-size: 13px;"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Update: Just to let you know, I left Microsoft to start a new company,&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;a href="http://www.raveable.com/" class="" mce_href="http://www.raveable.com" style="color: rgb(0, 101, 226);"&gt;Raveable Hotel Reviews&lt;/a&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;. See examples:&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;a href="http://www.raveable.com/sc/myrtle-beach/top-10-hotels-in-myrtle-beach/l6180c3" mce_href="http://www.raveable.com/sc/myrtle-beach/top-10-hotels-in-myrtle-beach/l6180c3" style="color: rgb(0, 101, 226);"&gt;Top 10 Hotels in Myrtle Beach&lt;/a&gt;,&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.raveable.com/ny/new-york-city/best-hotels-in-new-york-city/l5039c1" title="best hotels in NYC" mce_href="http://www.raveable.com/ny/new-york-city/best-hotels-in-new-york-city/l5039c1" style="color: rgb(0, 101, 226);"&gt;Best Hotels in New York City&lt;/a&gt;,&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.raveable.com/wa/seattle/romantic-hotels-in-seattle/l7344c2" mce_href="http://www.raveable.com/wa/seattle/romantic-hotels-in-seattle/l7344c2" style="color: rgb(0, 101, 226);"&gt;Romantic Hotels in Seattle&lt;/a&gt;&lt;/b&gt;,&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;a href="http://www.raveable.com/hotels-with-kitchen" title="hotels with kitchen or kitchenette" mce_href="http://www.raveable.com/hotels-with-kitchen" style="color: rgb(0, 101, 226);"&gt;Hotels with a kitchen or kitchenette&lt;/a&gt;&lt;/b&gt;&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;and&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;a href="http://www.raveable.com/ca/san-francisco/top-10-hotels-in-san-francisco/l717c3" title="top 10 hotels in san francisco" mce_href="http://www.raveable.com/ca/san-francisco/top-10-hotels-in-san-francisco/l717c3" style="color: rgb(0, 101, 226);"&gt;Top 10 Hotels in San Francisco&lt;/a&gt;&lt;/b&gt;. Your feedback is welcome on&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://twitter.com/raveable" mce_href="http://twitter.com/raveable" style="color: rgb(0, 101, 226);"&gt;twitter.com/raveable&lt;/a&gt;,&lt;span class="Apple-converted-space"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://blog.raveable.com/" mce_href="http://blog.raveable.com" style="color: rgb(0, 101, 226);"&gt;raveable blog&lt;/a&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span class="Apple-converted-space"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="word-spacing: 0px; font-family: Arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 13px; line-height: normal; font-size-adjust: none; font-stretch: normal; text-transform: none; color: rgb(0, 0, 0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2;"&gt;I am not actively blogging about Sync Technologies. Please see &lt;a href="http://blogs.msdn.com/sync/" class="" mce_href="http://blogs.msdn.com/sync/"&gt;Sync Team Blog&lt;/a&gt; for more updated content. &lt;br&gt;&lt;/span&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7497291" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/synchronizer/attachment/7497291.ashx" length="10864" type="image/jpeg" /><category domain="http://blogs.msdn.com/synchronizer/archive/tags/SQL2008/default.aspx">SQL2008</category><category domain="http://blogs.msdn.com/synchronizer/archive/tags/SqlChangeTracking/default.aspx">SqlChangeTracking</category></item></channel></rss>