An error occurred while attaching the database to SQL Server. Error code: 5123, sql5123
Today, when I attached a previous database (not in the directory where SQL Server was initially installed), I was always unable to append it, and there was always a 5123 error code,
At first, I thought it was because SqlServer2008 was not compatible with the original database because the database was not known to be created in that version. I read it on the official website and explained that the permission was incorrect, put the database in the directory where SqlServer is installed, that is, X: \ Program Files \ Microsoft SQL Server \ MSSQL10.MSSQLSERVER \ MSSQL \ DATA, which solves the problem; however, you cannot put the database in this directory every time! So I found other solutions;
Solution 1: This is the method just now. Put this file in the default location of SqlServer, but it is best not to put it on disk C. If you reinstall the system that day, it will be finished, haha;
Solution 2: It is to change the default database folder of the Sqlserver real column, select the Sqlserver instance, right-click the attribute, there is a "database Settings" on the left, after clicking it, there is a "default database location ", set this to your own directory.
Solution 3: Change the permissions of the folder where the database is located. Add an EveryOne user and set it to "full control". This solution is convenient and direct;
According to the editor of the customer's house, the third type is recommended for local testing. For the server, you still need to set the permissions.