|
1 | 1 | --- |
2 | 2 | title: "MSSQLSERVER_5228 | Microsoft Docs" |
3 | 3 | ms.custom: "" |
4 | | -ms.date: "04/04/2017" |
| 4 | +ms.date: 07/10/2020 |
5 | 5 | ms.prod: sql |
6 | 6 | ms.reviewer: "" |
7 | 7 | ms.technology: supportability |
@@ -34,7 +34,7 @@ ms.author: mathoma |
34 | 34 | Diagnose and correct the operating system error, then retry the operation. There are multiple states that can help Microsoft narrow down the area in the product where the area is occurring. |
35 | 35 |
|
36 | 36 | ### Access is denied |
37 | | -If you are getting the ```Access is Denied``` operating system error = 5, consider these methods: |
| 37 | +If you are getting the `Access is Denied` operating system error = 5, consider these methods: |
38 | 38 | - Check the permissions that are set of the file by looking at the properties of the file in Windows Explorer. [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] uses Windows groups to provision Access Control on the various file resources. Make sure the appropriate group [with names like SQLServerMSSQLUser$ComputerName$MSSQLSERVER or SQLServerMSSQLUser$ComputerName$InstanceName] has the required permissions on the database file that is mentioned in the error message. Review [Configure File System Permissions for Database Engine Access](../../2014/database-engine/configure-windows/configure-file-system-permissions-for-database-engine-access.md) for more details. Ensure that the Windows group actually includes the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service startup account or the service SID. |
39 | 39 | - Review the user account under which the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service is currently running. You can use the Windows Task Manager to get this information. Look for the "User Name" value for the executable "sqlservr.exe". Also if you recently changed the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] service account, know that the supported way to do this operation is to use the [SQL Server Configuration Manager](../sql-server-configuration-manager.md) utility. |
40 | 40 | - Depending on the type of operation (opening databases during server startup, attaching a database, database restore, and so on), the account that is used for impersonation and accessing the database file may vary. Review the topic [Securing Data and Log Files](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms189128(v=sql.105)?redirectedfrom=MSDN) to understand which operation sets what permission and to which accounts. Use a tool like Windows SysInternals [Process Monitor](https://docs.microsoft.com/sysinternals/downloads/procmon) to understand if the file access is happening under the security context of the [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] instance service startup account [or Service SID] or an impersonated account. |
@@ -62,21 +62,21 @@ If you are getting the ```Access is Denied``` operating system error = 5, consid |
62 | 62 | ### Attaching files that reside on a network-attached storage |
63 | 63 | If you cannot re-attach a database that resides on network-attached storage, a message like this may be logged in the Application log. |
64 | 64 |
|
65 | | -```Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "\\servername\sharename\filename.mdf". Operating system error 5: (Access is denied.).``` |
| 65 | +`Msg 5120, Level 16, State 101, Line 1 Unable to open the physical file "\\servername\sharename\filename.mdf". Operating system error 5: (Access is denied.).` |
66 | 66 |
|
67 | 67 | This problem occurs because [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] resets the file permissions when the database is detached. When you try to reattach the database, a failure occurs because of limited share permissions. |
68 | 68 |
|
69 | 69 | To resolve, follow these steps: |
70 | 70 | 1. Use the -T startup option to start [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. Use this startup option to turn on trace flag 1802 in [SQL Server Configuration Manager](../sql-server-configuration-manager.md) (see [Trace Flags](../../t-sql/database-console-commands/dbcc-traceon-transact-sql.md) for information on 1802). For more information about how to change the startup parameters, see [Database Engine Service Startup Options](../../database-engine/configure-windows/database-engine-service-startup-options.md). |
71 | 71 |
|
72 | 72 | 2. Use the following command to detach the database. |
73 | | - ```tsql |
| 73 | + ```sql |
74 | 74 | exec sp_detach_db DatabaseName |
75 | 75 | go |
76 | 76 | ``` |
77 | 77 |
|
78 | 78 | 3. Use the following command to reattach the database. |
79 | | - ```tsql |
| 79 | + ```sql |
80 | 80 | exec sp_attach_db DatabaseName, '\\Network-attached storage_Path\DatabaseMDFFile.mdf', '\\Network-attached storage_Path\DatabaseLDFFile.ldf' |
81 | 81 | go |
82 | 82 | ``` |
|
0 commit comments