A few confusions in the generated code for sync with visual studio wizard RRS feed

  • Question

  • I have a table that has a version timestamp column. No creation date. Running the visual studio wizard with the localdatacache. It creates 2 triggers one for insert and one for delete. It also create an additional column CreationDate => DEFAULT VALUES TO @@DBTS + 1.

    First confusion : It has created and additional column with a default value. BUT in the trigger for insert, it also set the CreationDate to @@DBTS + 1 .... ??? Why is there a trigger for the insert .... it seems like the default value for the CreationDate column should suffice ...

    Second confusion .. or bug ? : Whenever I delete a record it also set the DeletionDate = @@DBTS + 1. So let's say the currently the @@DBTS is 2014. Now when I delete a row it will set the DeletionDate to 2015. And the @@DBTS still is 2014.  In the generated SelectIncrementalDeleteChanges it will do a select based on this where statement

    "SELECT [Id], [DeletionDate] FROM dbo.Table_2_Tombstone WHERE (@sync_initialized = 1 AND [DeletionDate] > @sync_last_received_anchor AND [DeletionDate] <= @sync_new_received_anchor)"

    The @sync_new_received_anchor = @@DBTS (which is also generated from visual studio) (I'm aware its better to use min_active_rowversion) 

    So in our example @sync_new_received_anchor = 2014. 

    So the issue I'm getting is that the deleted record is not being downloaded on the client side ... 


    Monday, July 12, 2010 7:36 PM


All replies

  • the @@DBTS should change automatically whenever there's a change. so in your case, when 2015 was set, @@DBTS would have changed as well.
    Sunday, July 18, 2010 2:58 PM
  • It didn't change because in the DeletedDate, by default it use @@DBTS + 1 = 2014 + 1 = 2015, but @@DBTS is still 2014. 


    "@@DBTS returns the last-used timestamp value of the current database. A new timestamp value is generated when a row with a timestamp column is inserted or updated."


    Meaning the deleted record does not affect the @@DBTS. 

    Monday, July 19, 2010 1:10 PM
  • is your DeletedDate column not a timestamp column?
    • Marked as answer by GoDaddy Monday, July 19, 2010 3:41 PM
    Monday, July 19, 2010 2:41 PM
  • It's a bigint column .... that's what has been generated by visual studio wizard for localdatacache ...

    Hmm so If I change it to a timestamp it should fix the issue. I will try



    Monday, July 19, 2010 3:28 PM
  • I've test it out and works! Thanks


    It's weird though that through the visual studio wizard for the localdatacache, it doesn,t allow you to specify a timestamp for the deletion column....

    Monday, July 19, 2010 3:42 PM