I won't say much about the long-winded words, let's get straight to the point!
Option 1:
In this situation, the SA account is generally used to log in, as long as it is changed to Windows authentication, and then the database can be attached.
Option 2:
Use sa to log in to SQL Server 2008 to attach the database, after attaching the database is read-only, then click on the database --> "Properties" --> "Options" --> "Status", and find that the item "Database is read-only" is true, change it to false, if you can modify it, then congratulations, your character is good! I reported this error again when I was modifying:
In this case, find your data files and log files, right-click on "Properties" -> "Security", add a "Network Service" account, and give the account full control. Login again with sa, attach database, hehe... You will find that life is so beautiful!!
Title: Microsoft SQL Server Management Studio ------------------------------
Change for database "xxx" failed. (Microsoft.SqlServer.Smo)
For help information, please click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.2100.60+((SQL11_RTM).120210-1917+)&EvtSrc= Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Change+Database&LinkId=20476
------------------------------ Additional information:
An exception occurred when executing a Transact-SQL statement or batch processing. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Unable to open the physical file "D:\SqlData\xxx.mdf". OS error 5: "5 (Access denied. )”。 Unable to open the physical file "D:\SqlData\xxx_log.ldf". OS error 5: "5 (Access denied. )”。 Database "xxx" cannot be restarted. will revert to the previous state. ALTER DATABASE statement failed. (Microsoft SQL Server, Error: 5120)
For help information, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.2100&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476
------------------------------ Button:
Are you sure ------------------------------
The above operation did not solve my problem.My workaround is to set Users to full control of the database folder, solved! The database version is 2012
|