Pages

Search This Blog

Showing posts with label mdf. Show all posts
Showing posts with label mdf. Show all posts

Sunday, November 28, 2010

[T-SQL] What to do , if mdf file get corrupted

Today one of my old friend asked help that he has got mdf file corrupted so what should he do.

So normally there are different excersies which one can do if he knows about the structure of sql server but i am suggesting two tool which you can download and get the task done.:

http://www.mdfrepair.com/
http://www.nucleustechnologies.com/sql-recovery.html

Download it and there are simple steps what you can do to get your db repaired.

Tuesday, October 5, 2010

[T-SQL] Restore database trough mdf file only , ldf missing

One of my friend just call me and told that he has an mdf file but no ldf file , so if want to restore db then what to do , i searched over internet and found two fastest methods for it

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\MSSQL\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

Thursday, August 5, 2010

[T-SQL] Attach mdf file without ldf file in Database

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\MSSQL\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