Technology Software

How to Attach an MDF File

    • 1). Create a database in Microsoft SQL Server called 'Demand', Here is the SQL command to issue in a query window, it uses defaults for everything but the database name: create database Demand

    • 2). Determine where the MDF and LDF files of the database are actually stored on the hard drive: sp_Helpdb Demand

      By default it will be somewhere such as: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data

    • 3). Detach the MDF and LDF files from the Microsoft SQL Server instance: sp_detach_db Demand

    • 4). Open the location where the files are stored and either delete the Demand.LDF file or change its name. This will simulate only having the MDF available to attach.

    • 5). Attach the MDF file to the Microsoft SQL server instance by issuing the following command in a query window, change the database name and file path accordingly: EXEC sp_attach_db @dbname = N'Demand',
      @filename1 = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Demand.mdf'

      You should get a message similar to: File activation failure. The physical file name "c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\Demand_log.LDF" may be incorrect.
      New log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Demand_log.LDF' was created.

      The Microsoft SQL Server tried to reattach the default LDF file, but since it was missing the server just created a new log file.

SHARE
RELATED POSTS on "Technology"
How Do I Print Business Cards With Microsoft Publisher?
How Do I Print Business Cards With Microsoft Publisher?
How to Reduce the Size of Photos Using Adobe Photoshop Elements 3.0
How to Reduce the Size of Photos Using Adobe Photoshop Elements 3.0
Features and Benefits of Project Portfolio Management
Features and Benefits of Project Portfolio Management
Fix Registry - Fix Registry Errors Easily
Fix Registry - Fix Registry Errors Easily
Business Intelligence Solutions and Services
Business Intelligence Solutions and Services
AutoCAD Architecture
AutoCAD Architecture
Best Social Networking Apps
Best Social Networking Apps
IKE
IKE
Help Desk Software by help-desk-software
Help Desk Software by help-desk-software
What's Better - Building a BPM Solution Or Buying One?
What's Better - Building a BPM Solution Or Buying One?
How to Make Music Fade out in Moviemaker
How to Make Music Fade out in Moviemaker
How to Shrink a DVD With Nero Instructions
How to Shrink a DVD With Nero Instructions
Live Chat Software: Four Tips To Help You Get the Most Out of Your Software
Live Chat Software: Four Tips To Help You Get the Most Out of Your Software
How to Stop Rootkits
How to Stop Rootkits
3 First-Rate Foundations for Making Movies
3 First-Rate Foundations for Making Movies
How to Build Game Downloads
How to Build Game Downloads
The Linux Modem How-To
The Linux Modem How-To
Text-Terminals on Linux - 11.6 Terminal Server Connection
Text-Terminals on Linux - 11.6 Terminal Server Connection
The Linux Loadable Kernel Module How-To
The Linux Loadable Kernel Module How-To
How to Create Photo Albums With CSS
How to Create Photo Albums With CSS

Leave Your Reply

*