Updated on February 23rd, 2022
This is a very common error which may occur during migration of SQL Database files. The reason may be due to the corruption of files or due to different file names. Therefore the user encounters error 5173 cannot associate files with different databases. In this article, I am going to discuss how to resolve this error manually.
In a layman term, this error occurs when the user tries to open the SQL database and due to corruption or missing content the file doesn’t open. This is an attach error where the user has moved from one database to another but after migration, he is not able to access the file.
There is a lot more to tell about this error but we can discuss it later. First of all, let’s see how we can resolve this error.
You can use the sp_helpfile system to view all the files present on the database. It will show you the file size, location, and ID.
You May Also Read- Fix SQL Server Error 945.
The primary data file doesn’t match the log file and therefore the user faces such errors. It can be fixed:-
You can Download the Software form below:-
The MS SQL Database Recovery software helps the user to repair the MDF file and then the user will not face such errors. It also supports BLOB, Images, XML and large page data. This tool is compatible with all the versions of windows.
If you are having some problem with the LDF file then you can recreate it.
If you are unable to find the correct LDF file then you can rebuild it for the MDF file that you have recently recovered. Enter the following SQL code to Rebuild the File.
CREATE DATABASE yourdatabase
ON (FILENAME = ‘c:\yourPrimaryFile_Data.mdf’)
FOR ATTACH_REBUILD_LOG ;
A new database would be created on the MDF file. By this attach_rebuild_log code, you can create a new log file for the MDF files.
So the error 5173 cannot associate files with different databases occurs when there is a problem in the MDF file and in the Log file. Due to some negligence, the two files don’t match each other and the system interprets it as the files of two different databases.
But if the primary file is corrupted then you can repair it by using the third party software. Once you repaired it then you can match both the file by creating a new Log file using attach_build_log. Hope you liked this article.
About The Author:
© Copyrights 2014-2023 Recovery & Management is an Affiliate Partner of Sysinfo Tools Software Pvt. Ltd.