Setting ddl_username and ddl_password

To replicate DDL in Microsoft SQL Server, in addition to setting the value of pdb_setrepddl to enable, set the Replication Agent ddl_username and ddl_password parameters. The ddl_username parameter is the replicate database user name included in LTL for replicating DDL commands to the replicate or target database.

Permissions

In addition to the permission to execute all replicated DDL commands at the replicate database, the ddl_username should also have the impersonate permission granted for all users whose DDL commands may be replicated to the replicate database. This impersonate permission is necessary to switch session context in the replicate database when executing a DDL command. This user switches context to apply the DDL command using the same privileges and default schema settings as the user who executed the DDL command at the primary database. To provide this context switch, the ddl_username user must have permission to execute the execute as user Microsoft SQL Server command for any user who might execute DDL commands to be replicated from the primary database.

For example, user1 with a default schema of schema1 executes the following DDL at the primary database:

create table tab1 (id int)

This results in the creation of a table named schema1.tab1 at the primary database. At the replicate database, user2 with a default schema of schema2, cannot immediately execute this DDL because it will generate a table named schema2.tab1. Therefore, user2, whose name is specified by the ddl_username configuration parameter, must first execute the following command at the replicate database to impersonate user1:

execute as user = 'user1'

The DDL can then be executed with the correct schema by user2 at the replicate database, generating a table named schema1.tab1.

See the Replication Agent Reference Manual.

Granting impersonate permission

There are two ways to grant impersonate permission to the ddl_username user:

NoteThis grant command must be executed in the replicate database, where the user defined to ddl_username executes the DDL commands.

When you replicate DDL in Microsoft SQL Server, use Microsoft SQL Server as the replicate database. You cannot replicate DDL commands from Microsoft SQL Server to non-Microsoft SQL Server replicate databases.

NoteTo replicate DDL, Replication Server must have a database-level replication definition with replicate DDL set in the definition. See the Replication Server Reference Manual.


DDL commands and objects filtered from replication

The following database-scope DDL commands are not replicated:

The following server-scope DDL commands are not replicated:

Any object owned by users defined in the list of non-replicated users is not replicated. You can modify this list using the pdb_ownerfilter command. In addition, Sybase has provided a default list of owners whose objects will not be replicated. Use the pdb_ownerfilter command to return, add, or remove the list of owners whose objects will not be replicated. See the Replication Agent Reference Manual.