USE master;
GO
CREATE DATABASE bugtrackertest
ON (FILENAME = 'C:\DATA\bugtracker.mdf'),
(FILENAME = 'C:\DATA\bugtracker_log.ldf')
FOR ATTACH;
GO
How to create a new database with existing MDF and LDF files
Hello.
I am running SQL Server 2016 with the Studio 2019 release, and I would like to create a new database with its own name, using existing MDF an LDF files. The name of the original database is 'bugtracker', and the name of the new database will be 'bugtrackertest'. The files in question are those restored from a backup, and their names are bugtracker.mdf, and bugtracker.ldf respectively.
I have gone into Studio, and have selected the 'Attach' option under the 'Databases' menu item. The Attach Databases window has appeared on-screen, and I am able to select the corresponding MDF and LDF files. My question is the following: If I want to create the new database as described above, do I modify the name of the database in the 'Attach As' field, or is there more that needs to be done?
SQL Server Other
-
Jingyang Li 5,896 Reputation points Volunteer Moderator
2023-11-20T19:45:14.5033333+00:00