PurgeTombstoneTableData Method

Purges tombstone data for the specified table.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

Syntax

'Declaration
Public Sub PurgeTombstoneTableData ( _
    tableName As String, _
    pType As PurgeType, _
    retentionValue As Long _
)
'Usage
Dim instance As SqlCeChangeTracking
Dim tableName As String
Dim pType As PurgeType
Dim retentionValue As Long

instance.PurgeTombstoneTableData(tableName, _
    pType, retentionValue)
public void PurgeTombstoneTableData(
    string tableName,
    PurgeType pType,
    long retentionValue
)
public:
void PurgeTombstoneTableData(
    String^ tableName, 
    PurgeType pType, 
    long long retentionValue
)
member PurgeTombstoneTableData : 
        tableName:string * 
        pType:PurgeType * 
        retentionValue:int64 -> unit 
public function PurgeTombstoneTableData(
    tableName : String, 
    pType : PurgeType, 
    retentionValue : long
)

Parameters

  • retentionValue
    Type: System. . :: . .Int64
    A number that specifies the limit up to which tombstone rows should be retained. In the case of a time based purge the parameter specifies the number of days from the present date for which to retain tombstone data. In the case of a CSN based purge, the parameter specifies the CSN of the last transaction for which tombstone data should be retained.

Exceptions

Exception Condition
ArgumentOutOfRangeException

retentionValue is less than zero.

-or-

purgeType is not a valid PurgeType value.

Remarks

The PurgeTombstoneTableData method deletes (purges) rows from the tombstone table (__sysOCSDeletedRows). When rows are deleted from a tracked table, the tracking infrastructure moves the deleted rows to the tombstone table. Over time, this table can grow quite large because the tracking infrastructure uses the tombstone table to hold deleted rows for all tracked tables in the system. You can use the PurgeTombstoneTableData method to limit the size of the tombstone table by periodically purging rows from it.

You can specify one of two types of purge by using the pType parameter:

  • A time based purge. In the case of a time based purge, the retentionValue parameter specifies the number of days from the current date for which rows are retained in the tombstone table. Any row in the specified table that was deleted on or after the retention date is retained in the tombstone table; any row that was deleted before the retention date is deleted from the tombstone table.

  • A CSN based purge. This type of purge is also known as a transaction based purge. In the case of a CSN based purge, the retentionValue parameter specifies the transaction commit sequence number (CSN) of the last transaction for which to retain rows in the tombstone table. Any rows that were deleted from the specified table by a transaction with a CSN that is greater than or equal to the specified CSN are retained in the tombstone table; those that were deleted by a transaction with a CSN less than the specified CSN are deleted from the tombstone table. You can get the current CSN for a data source (the CSN assigned to the last transaction to commit) by calling the GetLastCommittedCsn method.

    Note

    The CSN is a monotonically incrementing counter that is assigned by the database to each transaction (in which the database is enlisted) when it commits. The CSN uniquely identifies the sequence in which each transaction was committed relative to other transactions that that have committed in which the database was also enlisted.

For more information about the differences between performing a time based purge and a CSN based purge, see the topic for the PurgeType enumeration.

See Also

Reference

SqlCeChangeTracking Class

SqlCeChangeTracking Members

System.Data.SqlServerCe Namespace

PurgeType