Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Unhappy Unanswered: restoring database from ldf and mdf files

    Hi all,
    i have a problem because of wrong back up (if it is called a backup). I have only copied the ldf and mdf files of from C:\Program Files\Microsoft SQL Server\MSSQL\Data directory and formatted the pc. (no any other backup function/tool). now i installed SQL server and copied the ldf and mdf files to their original directory. As you guess i dont see the databases.
    Can you tell me if i lost these data or not. If there is a way to restore them how can i do it?
    Thank you very much..

  2. #2
    Join Date
    Oct 2003
    Location
    Bangalore, India
    Posts
    27

    Re: restoring database from ldf and mdf files

    Originally posted by harunca
    Hi all,
    i have a problem because of wrong back up (if it is called a backup). I have only copied the ldf and mdf files of from C:\Program Files\Microsoft SQL Server\MSSQL\Data directory and formatted the pc. (no any other backup function/tool). now i installed SQL server and copied the ldf and mdf files to their original directory. As you guess i dont see the databases.
    Can you tell me if i lost these data or not. If there is a way to restore them how can i do it?
    Thank you very much..
    If you have created the original databse in the MSSQL\Data folder and copied the same back to the new original directory then fine.
    Do one thing.
    Open the SQL Query analyser and connect to the SQL Server and run the below mentioned command :-

    EXEC sp_attach_db @dbname = N'DBName',
    @filename1 = N'Path of the MDF file',
    @filename2 = N'Path of the LDF file'

    You will get these Databases attached back with the name you have mentioned in the sp_attach_db command.

    Hope this one is helpfull..

    --Sandu_Bangalore

  3. #3
    Join Date
    Oct 2003
    Posts
    2

    Smile Re: restoring database from ldf and mdf files

    It worked, everything is fine.
    Thank you very much


    Originally posted by sandu_bangalore
    If you have created the original databse in the MSSQL\Data folder and copied the same back to the new original directory then fine.
    Do one thing.
    Open the SQL Query analyser and connect to the SQL Server and run the below mentioned command :-

    EXEC sp_attach_db @dbname = N'DBName',
    @filename1 = N'Path of the MDF file',
    @filename2 = N'Path of the LDF file'

    You will get these Databases attached back with the name you have mentioned in the sp_attach_db command.

    Hope this one is helpfull..

    --Sandu_Bangalore

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •