|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Create MDF from DatabaseHow does one create an .MDF file from the contents of an existing SQL Server
database? I've tried backing up the SQL database, then restoring it to an attached ..MDF database, but this doesn't work if the other database is still being managed by SQL Server, due to a name conflict. There must be some easy way to do this. If you have a database, you already have an .MDF file. That is where your
database is actually stored on disk. What are you trying to do? -- Show quoteHTH Kalen Delaney, SQL Server MVP "porko" <po***@discussions.microsoft.com> wrote in message news:60DBF209-EC39-4DE4-8590-B167A85ED839@microsoft.com... > How does one create an .MDF file from the contents of an existing SQL > Server > database? > > I've tried backing up the SQL database, then restoring it to an attached > .MDF database, but this doesn't work if the other database is still being > managed by SQL Server, due to a name conflict. > > There must be some easy way to do this. porko (po***@discussions.microsoft.com) writes:
> How does one create an .MDF file from the contents of an existing SQL You can restore a backup and create new database at the same time.> Server database? > > I've tried backing up the SQL database, then restoring it to an attached > .MDF database, but this doesn't work if the other database is still being > managed by SQL Server, due to a name conflict. > > There must be some easy way to do this. Say that you have a database porko, and you want to create a copy, porko_copy. First you backup porko to, say, C:\temp\porko.bak. Next you can restore porko_copy as RESTORE DATABASE porko_copy FROM DISK = 'C:\temp\porko.bak' WITH MOVE 'porko_Data' TO 'C:\program files\Microsoft SQL Server\MSSQL\Data\porko_copy.mdf', MOVE 'porko_Log' TO 'C:\program files\Microsoft SQL Server\MSSQL\Data\porko_copy.ldf', REPLACE porko_Data and porko_Log rae the logical file names for the database files. -- Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
|||||||||||||||||||||||