Monday, March 26, 2012

NEWBIE Question - How do I take an existing Database and Create an exact Copy of it under

Ladies / Gentlemen
How do I take an existing Database and Create an Exact Copy of it
under a new Database Name and having the name of the Database .MDF and .LOG
files changed also?
Thanks for your help.
Mark MossHow about backup/restore (using the MOVE option for the RESTORE command)?
Or detach, copy files, then attach?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Mark Moss" <markmoss@.adelphia.net> wrote in message news:OGyb3Q%23mHHA.668@.TK2MSFTNGP05.phx.gbl...
> Ladies / Gentlemen
>
> How do I take an existing Database and Create an Exact Copy of it under a new Database Name
> and having the name of the Database .MDF and .LOG files changed also?
>
> Thanks for your help.
>
> Mark Moss
>|||Hi Mark
Since you did not mention your version number I will assume SQL Server 2005.
Please refer to the BOL (Books Online) documentation for syntax details:
Detach the original database using sp_detach_db
Copy the .mdf and .ldf files and give them new names.
Use CREATE DATABASE ... FOR ATTACH to create the new database using the
copied files.
Also see the following in BOL:
How to: Move a Database Using Detach and Attach (Transact-SQL)
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://sqlblog.com
"Mark Moss" <markmoss@.adelphia.net> wrote in message
news:OGyb3Q%23mHHA.668@.TK2MSFTNGP05.phx.gbl...
> Ladies / Gentlemen
>
> How do I take an existing Database and Create an Exact Copy of it
> under a new Database Name and having the name of the Database .MDF and
> .LOG files changed also?
>
> Thanks for your help.
>
> Mark Moss
>|||Another new thing for me! "... FOR ATTACH" option of CREATE DATABASE.
--
TheSQLGuru
President
Indicium Resources, Inc.
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:ul1ggW%23mHHA.5032@.TK2MSFTNGP02.phx.gbl...
> Hi Mark
> Since you did not mention your version number I will assume SQL Server
> 2005.
> Please refer to the BOL (Books Online) documentation for syntax details:
>
> Detach the original database using sp_detach_db
> Copy the .mdf and .ldf files and give them new names.
> Use CREATE DATABASE ... FOR ATTACH to create the new database using the
> copied files.
> Also see the following in BOL:
> How to: Move a Database Using Detach and Attach (Transact-SQL)
> --
> HTH
> Kalen Delaney, SQL Server MVP
> www.InsideSQLServer.com
> http://sqlblog.com
>
> "Mark Moss" <markmoss@.adelphia.net> wrote in message
> news:OGyb3Q%23mHHA.668@.TK2MSFTNGP05.phx.gbl...
>> Ladies / Gentlemen
>>
>> How do I take an existing Database and Create an Exact Copy of it
>> under a new Database Name and having the name of the Database .MDF and
>> .LOG files changed also?
>>
>> Thanks for your help.
>>
>> Mark Moss
>>
>

No comments:

Post a Comment