--- title: "MSSQL_ENG021798 | Microsoft Docs" ms.custom: "" ms.date: "03/14/2017" ms.prod: sql ms.prod_service: "database-engine" ms.reviewer: "" ms.technology: replication ms.topic: conceptual helpviewer_keywords: - "MSSQL_ENG021798 error" ms.assetid: 596f5092-75ab-4a19-8582-588687c7b089 author: "MashaMSFT" ms.author: "mathoma" monikerRange: "=azuresqldb-mi-current||>=sql-server-2016||=sqlallproducts-allversions" --- # MSSQL_ENG021798 [!INCLUDE[appliesto-ss-asdbmi-xxxx-xxx-md](../../includes/appliesto-ss-asdbmi-xxxx-xxx-md.md)] ## Message Details ||| |-|-| |Product Name|SQL Server| |Event ID|21798| |Event Source|MSSQLSERVER| |Component|[!INCLUDE[ssDEnoversion](../../includes/ssdenoversion-md.md)]| |Symbolic Name|| |Message Text|The '%s' agent job must be added through '%s' before continuing. Please see the documentation for '%s'.| ## Explanation To create a publication, you must be a member of the **sysadmin** fixed server role on the Publisher or a member of the **db_owner** fixed database role in the publication database. If you are a member of the **db_owner** role, this error is raised if: - You run scripts from [!INCLUDE[ssVersion2000](../../includes/ssversion2000-md.md)]. The security model changed in [!INCLUDE[ssVersion2005](../../includes/ssversion2005-md.md)], and these scripts must be updated. - The stored procedure **sp_addpublication** is executed before executing [sp_addlogreader_agent (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-addlogreader-agent-transact-sql.md). This applies to all transactional publications. - The stored procedure **sp_addpublication** is executed before executing [sp_addqreader_agent (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-addqreader-agent-transact-sql.md). This applies to transactional publications that are enabled for queued updating subscriptions (a value of TRUE for the `@allow_queued_tran` parameter of **sp_addpublication**). The stored procedures **sp_addlogreader_agent** and **sp_addqreader_agent** each create an agent job and allow you to specify the [!INCLUDE[msCoName](../../includes/msconame-md.md)] Windows account under which the agent runs. For users in the **sysadmin** role, agent jobs are created implicitly if **sp_addlogreader_agent** and **sp_addqreader_agent** are not executed; agents run under the context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] Agent service account at the Distributor. Although **sp_addlogreader_agent** and **sp_addqreader_agent** are not required for users in the **sysadmin** role, it is a security best practice to specify a separate account for the agents. For more information, see [Replication Agent Security Model](../../relational-databases/replication/security/replication-agent-security-model.md). ## User Action Ensure you execute procedures in the correct order. For more information, see [Create a Publication](../../relational-databases/replication/publish/create-a-publication.md). If you have replication scripts from previous versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], update these scripts to include the stored procedures and parameters required by [!INCLUDE[ssVersion2005](../../includes/ssversion2005-md.md)] and later versions. For more information, see [Upgrade Replication Scripts (Replication Transact-SQL Programming)](../../relational-databases/replication/administration/upgrade-replication-scripts-replication-transact-sql-programming.md). ## See Also [Errors and Events Reference (Replication)](../../relational-databases/replication/errors-and-events-reference-replication.md)