Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Creating new database with existing MDF(only MDF) file. Expand / Collapse
Author
Message
Posted Wednesday, October 22, 2008 11:37 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 9:49 PM
Points: 1,507, Visits: 2,536
Dear All,

I have downloaded MDF of my database from live server to local server.
Now I want to create a database in loocal server pointing to this MDF file.
How can I do it..?


Thanks in advance.


Santhu.
Post #590254
Posted Wednesday, October 22, 2008 11:43 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, October 7, 2011 1:41 AM
Points: 346, Visits: 534
nairsanthu1977 (10/22/2008)
Dear All,

I have downloaded MDF of my database from live server to local server.
Now I want to create a database in loocal server pointing to this MDF file.
How can I do it..?


Thanks in advance.


Santhu.


Attach that MDF

USE [master]
GO
CREATE DATABASE [database_name] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\ .mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\ .ldf' )
FOR ATTACH ;
GO

in case if you dont have the /ldf file : use this

EXEC sp_attach_single_file_db @dbname = 'pubs',
@physname = 'C:\MSSQL\Data\pubs.mdf'



kshitij kumar
kshitij@krayknot.com
www.krayknot.com
Post #590257
Posted Friday, April 19, 2013 9:30 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, July 11, 2014 10:05 AM
Points: 4, Visits: 10
Good Post.

I forgot how to create a database from the .mdf and .ldf file but this reminded me.

Thanks
Post #1444485
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse