MaxDistributionRetention-Eigenschaft
Gets or sets the maximum retention period, in hours, before transactions are deleted from the distribution database.
Namespace: Microsoft.SqlServer.Replication
Assembly: Microsoft.SqlServer.Rmo (in Microsoft.SqlServer.Rmo.dll)
Syntax
'Declaration
Public Property MaxDistributionRetention As Integer
Get
Set
'Usage
Dim instance As DistributionDatabase
Dim value As Integer
value = instance.MaxDistributionRetention
instance.MaxDistributionRetention = value
public int MaxDistributionRetention { get; set; }
public:
property int MaxDistributionRetention {
int get ();
void set (int value);
}
member MaxDistributionRetention : int with get, set
function get MaxDistributionRetention () : int
function set MaxDistributionRetention (value : int)
Eigenschaftswert
Typ: System. . :: . .Int32
An Int32 value.
Hinweise
The MaxDistributionRetention property specifies the maximum retention period before transactions are deleted. Subscriptions that have not yet received replicated commands that are older than the maximum distribution retention period are marked as inactive.
The MaxDistributionRetention property can only be retrieved by members of the db_owner or replmonitor fixed database role on the distribution database, by users in the publication access list (PAL) of a publication using the distribution database, or by users with SELECT permission on the MSdistributiondbs system table in the distribution database.
The MaxDistributionRetention property can only be set by members of the sysadmin fixed server role at the Distributor.
Retrieving the MaxDistributionRetention property is equivalent to executing sp_helpdistributiondb.
Setting the MaxDistributionRetention property is equivalent to executing sp_adddistributiondb or sp_changedistributiondb.
The MaxDistributionRetention property is available with SQL Server 7.0, SQL Server 2000, and SQL Server 2005.
This namespace, class, or member is supported only in version 2.0 of the .NET Framework.
Beispiele
// Set the server and database names
string distributionDbName = "distribution";
string publisherName = publisherInstance;
string publicationDbName = "AdventureWorks2008R2";
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 AdventureWorks 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 = "AdventureWorks2008R2"
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 AdventureWorks 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