how to create new db from .mdf .ldf

  • I have a requirement to create a new db from copies of an existing db's .mdf and .ldf files. The new db will reside on the same server as the original db but will have a different name. How do you do this?

    thanks

  • EXEC sp_attach_db @dbname = N'<>',

    @filename1 = '<>',

    @filename2 = '<>'

  • First you must have these copies. You can not atach these files if they depend to original DB. They can not be shared to other DB at the same time

  • If the original database is present, why not make a backup of that database and then restore it with a different name for the database and the dat files.

     

    Dave

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply