How to Create Publications and Define Articles (Transact-SQL)
To create a snapshot or transactional publication
- Execute sp_replicationdboption to enable publication of the current database.
- Execute sp_addpublication with repl_freq set to snapshot to define the publication.
- Execute sp_addpublication_snapshot to create a Snapshot Agent, set the publication agent_id, and place the schema and data into the replication working directory.
- Execute sp_addarticle n times to define each article in the publication.
To define an article for a snapshot or transactional publication
- Execute sp_addarticle to define an article.
- Execute sp_articlefilter to filter a table horizontally.
- Execute sp_articlecolumn to filter a table vertically.
- Execute sp_articleview to create the synchronization object for an article when a table is filtered vertically or horizontally.
To create a merge publication
- Execute sp_replicationdboption to enable publication of the current database.
- Execute sp_addmergepublication to define the publication.
- Execute sp_addpublication_snapshot to create a Snapshot Agent and place the schema and data into the replication working directory.
- Execute sp_addmergearticle n times to define each article in the publication.
To define a merge article
- Execute sp_addmergearticle to define an article.
- Execute sp_addmergefilter to create a partitioned publication.