August 4, 2009 at 6:14 am
Hi, I have only mdf & ldf filed from sql server 2005.. by using these two files how to create new database or i dont know the ways to make it as a database.... if plz answer me....
regards,
kannak..........
August 4, 2009 at 7:06 am
Hi,
You can execute the following script. I am assuming only one mdf and ldf files (no ndf's)
CREATE DATABASE MYDB
ON
(FILENAME='D:\DATA\MYDB_DATA.MDF'),
(FILENAME='D:\LOGS\MYDB_LOG.LDF')
FOR ATTACH;
[font="Verdana"]Thanks
Chandra Mohan[/font]
August 4, 2009 at 2:54 pm
you can create it by using sp_attach_db command. Read BOL for more info.
Example here from BOL:
EXEC sp_attach_db @dbname = N'AdventureWorks',
@filename1 = N'c:\Program Files\Microsoft SQL Server
\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf',
@filename2 = N'c:\Program Files\Microsoft SQL Server
\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf' ;
SQL DBA.
August 4, 2009 at 7:26 pm
Hi Sanjay,
Microsoft recommends using create database dbname for attach instead of sp_attach_db.
From bol:
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. We recommend that you use CREATE DATABASE database_name FOR ATTACH instead. For more information, see CREATE DATABASE (Transact-SQL).
Check this link http://msdn.microsoft.com/en-us/library/ms179877(SQL.90).aspx]
[font="Verdana"]Thanks
Chandra Mohan[/font]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply