Sql – mdf file is corrupted now how can i recover the ms sql server 2008 database

sqlsql serversql-server-2008

My database .mdf file got corrupted and I have no means to get my schema s.I tried with a few soft wares available on the internet but its turns out that all of them being demo versions don't give back the repaired file.Is there any other means by which I can restore my db?
I am using MS SQL 2008

Best Answer

Go ahead and delete your .ldf file.

Then Execute the below scripts.There are three.So choose one according to your condition.

-- Method 1

 USE [master]
    GO
    -- Method 1: I use this method
    EXEC sp_attach_single_file_db @dbname='TestDb',
    @physname=N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQ\DATA\TestDb.mdf'
GO

-- Method 2:

CREATE DATABASE TestDb ON
(FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf')
FOR ATTACH_REBUILD_LOG
GO

Method 2: If one or more log files are missing, they are recreated again.

There is one more method which I am demonstrating here but I have not used myself before. According to Book Online, it will work only if there is one log file that is missing. If there are more than one log files involved, all of them are required to undergo the same procedure.

-- Method 3:

CREATE DATABASE TestDb ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf')
FOR ATTACH
GO

Source: http://blog.sqlauthority.com/2010/04/26/sql-server-attach-mdf-file-without-ldf-file-in-database/