Access Denied Error in SQL Server Snapshot Agent During Replication Setup

kevin stani 25 Reputation points
2024-08-24T17:41:58.88+00:00

Hi,
I'm trying to set up SQL Server Transactional Replication, but I'm encountering an "Access Denied" error during the Snapshot Agent's operation. The replication process is supposed to create a snapshot of the database, but it fails with the following error:

Error messages:

Source: mscorlib

Target Site: Void WinIOError(Int32, System.String)

Message: Access to the path 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\ReplData\unc\DESKTOP-3UGIOTT_CAMPUSNET2_PUB_CAMPUSNET\20240824192740' is denied.

Stack: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)

at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)

at Microsoft.SqlServer.Replication.Utilities.CreateDirectoryWithExtendedErrorInformation(String directory)

at Microsoft.SqlServer.Replication.Snapshot.SnapshotProvider.CreateSnapshotFolders()

at Microsoft.SqlServer.Replication.Snapshot.SqlServerSnapshotProvider.GenerateSnapshot()

at Microsoft.SqlServer.Replication.SnapshotGenerationAgent.InternalRun()

at Microsoft.SqlServer.Replication.AgentCore.Run() (Source: mscorlib, Error number: 0)

Get help: http://help/0

I've checked the permissions for the directory in question (C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\ReplData) and made sure that the MSSQLSERVER service has full control. However, the error persists.Steps Taken So Far:

Verified folder permissions for MSSQLSERVER and SYSTEM accounts.

Tried restarting the SQL Server Agent and the Snapshot Agent.

Checked the SQL Server Agent log for additional details.

I'm looking for guidance on how to resolve this "Access Denied" error so that the Snapshot Agent can successfully create the snapshot and proceed with the replication process.

SQL Server Other
{count} votes

Accepted answer
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2024-08-26T02:14:25.23+00:00

    Hi @kevin stani ,

    Please check your SQL server agent service account and make sure that account has the full permission on this folder. Which account that you specify to snapshot agent? Does this account has the full permission for this folder?


    If the answer is helpful, please click "Accept Answer" and kindly upvote it.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.