1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to view content damaged ms sql server database?

Discussion in 'Databases' started by annakorifal, May 29, 2015.

  1. #1
    Hi guys
    SEMrush
    I got a huge problem. One of my employes deleted a MSSQL Database instead of detach. Now i tried to recover the .mdf and .ldf file but when i trie to attach it it says. "File is not a primary database file"

    Anybody got an Idea how to fix this? It's very urgent.
     
    annakorifal, May 29, 2015 IP
    SEMrush
  2. baruraf

    baruraf Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    Right click on the database name.

    Select Tasks -> Shrink -> Database

    Then click OK!

    I usually open the Windows Explorer directory containing the database files so I can immediately see the effect.

    I was actually quite surprised this worked! Normally I've used DBCC before, but I just tried that and it didn't shrink anything so I tried the GUI (2005) and it worked great - freeing up 17Gb in 10 seconds

    Edit: In Full recovery mode this might not work, so you have to either back up the log first, or change to Simple recovery, then shrink the file.

    ps: Use MDF Viewer Tool from http://www.mdf.viewertool.com/
     
    Last edited: May 29, 2015
    baruraf, May 29, 2015 IP
  3. Taruna P

    Taruna P Greenhorn

    Messages:
    13
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #3
    Try using this..
    CREATE DATABASE DatabaseName ON
    (FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\DatabaseName.mdf')
    FOR ATTACH_REBUILD_LOG;

    For more info visit. http://blog.sqlauthority.com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/
     
    Taruna P, Jul 6, 2015 IP