Forum Discussion
Restore SQL 2019 Database from files
We lost our most current changes to our SQL 2019 database while trying to upgrade to windows 11. We've installed a new copy of SQL 2019 onto a new Windows 11 install. We have also restored the database from a full backup from Jan 2024 (this is the most recent full backup we have access to). We also have access to a copy of the C drive before our loss from a few weeks ago. For example we have all of the files and folders including: C/Program Files/Microsoft SQL Server and C/Program Files (x86)/Microsoft SQL Server. The question is can we copy certain files and/or folders over from our Jan 25 C backup to update our restored Jan 24 database? If so, what files and or folders would we need to copy over. Super appreciate the support.
3 Replies
- olafhelperBronze Contributor
We also have access to a copy of the C drive before our loss from a few weeks ago.
Does the copy include the database files .MDF + .LDF?
Then you can use/attach them as a database, see Attach a Database - SQL Server | Microsoft Learn
- TimBCopper Contributor
I think I can restore the database using SSMS and copying MDF and LDF files from my old C backup.
I found the following MDF and LDF files
For 1/4/2025 there are 4 MDF and 4 LDF files. I don't know if I need to only copy the HOPE_WW2 files ( 1 MDF and 1 LDF) or should I copy all 8 files
Using SSMS I can attach a database by selecting the MDF file.
Depending on the answer to which files I should copy over, I'm not sure which files to attach where.
1 or all 4 MDF in the "Databases to attach" section
1 or all 4 LDF in the "Associated Files" section
I also don't know if I need to do anything in the connection properties section
Thanks for the support
- TimBCopper Contributor
I found this link on how to use SQL Server Management Studio (SSMS) to attach a database via .mdf and .ldf files. https://learn.microsoft.com/en-us/sql/relational-databases/databases/attach-a-database?view=sql-server-ver16&f1url=%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(sql13.swb.attachdatabase.f1)%26rd%3Dtrue In my C drive search the most recent .mdf and .ldf files were created on 1/4/2025. I found 4 .mdf and 4 .ldf files
I don't know if I need to copy all 4 of these .mdf and .ldf files over or just the "Hope_WW2" Any help would be appreciated.
Depending on that answer I am also unsure on which files do I attach where using SSMS. If I am suppose to copy all 8 files over do I attach all 4 MDF files in the top section (Databases to attach)? Do I also attach all 4 LDF files in the lower section (Associated Files)?
Also the database name has changed. Not sure if I need to change anything else - like in the connection section. Appreciate the support!