I want to attach a database to SQL Server 2005 but I have only its .mdf
file
How can I attach it?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityI want to attach a database to SQL Server 2005 but I have only its .mdf
file
How can I attach it?
E.g like this:
CREATE DATABASE AdventureWorks2012 ON (FILENAME = '{drive}:\{file path}\AdventureWorks2012_Data.mdf') FOR ATTACH_REBUILD_LOG;
Simply,When you attach database, it will display Attach Database
dialog box in which click the logfile location and click the remove button. When you click OK, a logfile for you database will be created....
When you attach the mdf via the UI, select the ldf file in the list of files and remove it. A new one will be created.