Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note: This API is now obsolete.
Generates a string that contains the SQL code to provision the database for a particular scope.
Namespace: Microsoft.Synchronization.Data.SqlServer
Assembly: Microsoft.Synchronization.Data.SqlServer (in Microsoft.Synchronization.Data.SqlServer.dll)
Syntax
'Declaration
<ObsoleteAttribute("Use Constructor with SqlConnection and Script()")> _
Public Function Script ( _
targetDatabaseName As String _
) As String
'Usage
Dim instance As SqlSyncScopeProvisioning
Dim targetDatabaseName As String
Dim returnValue As String
returnValue = instance.Script(targetDatabaseName)
[ObsoleteAttribute("Use Constructor with SqlConnection and Script()")]
public string Script(
string targetDatabaseName
)
[ObsoleteAttribute(L"Use Constructor with SqlConnection and Script()")]
public:
String^ Script(
String^ targetDatabaseName
)
[<ObsoleteAttribute("Use Constructor with SqlConnection and Script()")>]
member Script :
targetDatabaseName:string -> string
public function Script(
targetDatabaseName : String
) : String
Parameters
- targetDatabaseName
Type: System.String
The name of the database for which the provisioning script should be generated.
Return Value
Type: System.String
The SQL code to provision the database for a particular scope.
Exceptions
| Exception | Condition |
|---|---|
| ArgumentException | targetDatabaseName is null reference (Nothing in Visual Basic) or empty. |
Examples
The following code example creates a provisioning object for the filtered_customer scope, specifies that base tables should not be created in the server database, and specifies that all synchronization-related objects should be created in a database schema named "Sync". As part of provisioning the scope, the code defines a filter on the Customer table. Only rows that match that filter will be synchronized. No filter is defined on the CustomerContact table; therefore all rows from that table will be synchronized. After provisioning options are defined, the Apply method is called to create the change-tracking infrastructure in the server database; and the provisioning script is written to a file. To view this code in the context of a complete example, see How To: Execute Database Synchronization (SQL Server).
SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(serverConn, scopeDesc);
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
serverConfig.ObjectSchema = "Sync";
// Specify which column(s) in the Customer table to use for filtering data,
// and the filtering clause to use against the tracking table.
// "[side]" is an alias for the tracking table.
serverConfig.Tables["Sales.Customer"].AddFilterColumn("CustomerType");
serverConfig.Tables["Sales.Customer"].FilterClause = "[side].[CustomerType] = 'Retail'";
// Configure the scope and change-tracking infrastructure.
serverConfig.Apply();
// Write the configuration script to a file. You can modify
// this script if necessary and run it against the server
// to customize behavior.
File.WriteAllText("SampleConfigScript.txt",
serverConfig.Script());
Dim serverConfig As New SqlSyncScopeProvisioning(serverConn, scopeDesc)
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip)
serverConfig.ObjectSchema = "Sync"
' Specify which column(s) in the Customer table to use for filtering data,
' and the filtering clause to use against the tracking table.
' "[side]" is an alias for the tracking table.
serverConfig.Tables("Sales.Customer").AddFilterColumn("CustomerType")
serverConfig.Tables("Sales.Customer").FilterClause = "[side].[CustomerType] = 'Retail'"
' Configure the scope and change-tracking infrastructure.
serverConfig.Apply()
' Write the configuration script to a file. You can modify
' this script if necessary and run it against the server
' to customize behavior.
File.WriteAllText("SampleConfigScript.txt", serverConfig.Script())