Compartir a través de


DistributionDatabase.MaxDistributionRetention Propiedad

Definición

Obtiene o establece el período de retención máximo, en horas, antes de que las transacciones se eliminen de la base de datos de distribución.

public:
 property int MaxDistributionRetention { int get(); void set(int value); };
public int MaxDistributionRetention { get; set; }
member this.MaxDistributionRetention : int with get, set
Public Property MaxDistributionRetention As Integer

Valor de propiedad

Valor Int32.

Ejemplos

// Set the server and database names
string distributionDbName = "distribution";
string publisherName = publisherInstance;
string publicationDbName = "AdventureWorks2012";

DistributionDatabase distributionDb;
ReplicationServer distributor;
DistributionPublisher publisher;
ReplicationDatabase publicationDb;

// Create a connection to the server using Windows Authentication.
ServerConnection conn = new ServerConnection(publisherName);

try
{
    // Connect to the server acting as the Distributor 
    // and local Publisher.
    conn.Connect();

    // Define the distribution database at the Distributor,
    // but do not create it now.
    distributionDb = new DistributionDatabase(distributionDbName, conn);
    distributionDb.MaxDistributionRetention = 96;
    distributionDb.HistoryRetention = 120;

    // Set the Distributor properties and install the Distributor.
    // This also creates the specified distribution database.
    distributor = new ReplicationServer(conn);
    distributor.InstallDistributor((string)null, distributionDb);

    // Set the Publisher properties and install the Publisher.
    publisher = new DistributionPublisher(publisherName, conn);
    publisher.DistributionDatabase = distributionDb.Name;
    publisher.WorkingDirectory = @"\\" + publisherName + @"\repldata";
    publisher.PublisherSecurity.WindowsAuthentication = true;
    publisher.Create();

    // Enable AdventureWorks2012 as a publication database.
    publicationDb = new ReplicationDatabase(publicationDbName, conn);

    publicationDb.EnabledTransPublishing = true;
    publicationDb.EnabledMergePublishing = true;
}
catch (Exception ex)
{
    // Implement appropriate error handling here.
    throw new ApplicationException("An error occured when installing distribution and publishing.", ex);
}
finally
{
    conn.Disconnect();
}
' Set the server and database names
Dim distributionDbName As String = "distribution"
Dim publisherName As String = publisherInstance
Dim publicationDbName As String = "AdventureWorks2012"

Dim distributionDb As DistributionDatabase
Dim distributor As ReplicationServer
Dim publisher As DistributionPublisher
Dim publicationDb As ReplicationDatabase

' Create a connection to the server using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Try
    ' Connect to the server acting as the Distributor 
    ' and local Publisher.
    conn.Connect()

    ' Define the distribution database at the Distributor,
    ' but do not create it now.
    distributionDb = New DistributionDatabase(distributionDbName, conn)
    distributionDb.MaxDistributionRetention = 96
    distributionDb.HistoryRetention = 120

    ' Set the Distributor properties and install the Distributor.
    ' This also creates the specified distribution database.
    distributor = New ReplicationServer(conn)
    distributor.InstallDistributor((CType(Nothing, String)), distributionDb)

    ' Set the Publisher properties and install the Publisher.
    publisher = New DistributionPublisher(publisherName, conn)
    publisher.DistributionDatabase = distributionDb.Name
    publisher.WorkingDirectory = "\\" + publisherName + "\repldata"
    publisher.PublisherSecurity.WindowsAuthentication = True
    publisher.Create()

    ' Enable AdventureWorks2012 as a publication database.
    publicationDb = New ReplicationDatabase(publicationDbName, conn)

    publicationDb.EnabledTransPublishing = True
    publicationDb.EnabledMergePublishing = True

Catch ex As Exception
    ' Implement appropriate error handling here.
    Throw New ApplicationException("An error occured when installing distribution and publishing.", ex)

Finally
    conn.Disconnect()

End Try

Comentarios

La MaxDistributionRetention propiedad especifica el período de retención máximo antes de que se eliminen las transacciones. Las suscripciones que aún no han recibido comandos replicados que son anteriores al período de retención de distribución máximo se marcan como inactivos.

Los MaxDistributionRetention miembros del rol fijo de base de datos de la db_owner base de datos de replmonitor distribución solo pueden recuperar la propiedad , los usuarios de la lista de acceso a la publicación (PAL) de una publicación mediante la base de datos de distribución o los usuarios con permiso SELECT en la tabla del sistema MSdistributiondbs de la base de datos de distribución.

La MaxDistributionRetention propiedad solo se puede establecer por miembros del sysadmin rol fijo de servidor en el distribuidor.

Recuperar la MaxDistributionRetention propiedad es equivalente a ejecutar sp_helpdistributiondb.

Establecer la MaxDistributionRetention propiedad es equivalente a ejecutar sp_adddistributiondb o sp_changedistributiondb.

Se aplica a

Consulte también