Thursday, March 22, 2012

duplicate database

Is there a way to copy/duplicate and rename a database on the same server? I
need to make a copy for another application. I appreciate any tips or advice
you can provide!

TIA - RobYou can do this by either detaching, renaming & attaching the database files
with a different name or you can backup the database & restore it as a
different name. For smaller databases, you can even do the Copy database
wizard which can create a copy of the database with a different name.

Please refer to SQL Server Books Online for details on any of these
approaches and check the following MSKB links :
http://support.microsoft.com/default.aspx?kbid=314546
http://support.microsoft.com/defaul...scid=kb;q224071

--
- Anith
( Please reply to newsgroups only )|||Thanks for the reply! I can copy with a number of methods but I always loose
the database rules when I copy or import data (i.e. primary keys, identity,
default values, etc.). Any ideas or tips to keep the database and rules
intact?

TIA - Rob

"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:iy9Yb.7035$hm4.4664@.newsread3.news.atl.earthl ink.net...
> You can do this by either detaching, renaming & attaching the database
files
> with a different name or you can backup the database & restore it as a
> different name. For smaller databases, you can even do the Copy database
> wizard which can create a copy of the database with a different name.
> Please refer to SQL Server Books Online for details on any of these
> approaches and check the following MSKB links :
> http://support.microsoft.com/default.aspx?kbid=314546
> http://support.microsoft.com/defaul...scid=kb;q224071
> --
> - Anith
> ( Please reply to newsgroups only )|||"Rob Wahmann" <rob@.dotcomstudio.biz> wrote in message news:<H0gYb.8966$PY.8805@.newssvr26.news.prodigy.com>...
> Thanks for the reply! I can copy with a number of methods but I always loose
> the database rules when I copy or import data (i.e. primary keys, identity,
> default values, etc.). Any ideas or tips to keep the database and rules
> intact?
> TIA - Rob
> "Anith Sen" <anith@.bizdatasolutions.com> wrote in message
> news:iy9Yb.7035$hm4.4664@.newsread3.news.atl.earthl ink.net...
> > You can do this by either detaching, renaming & attaching the database
> files
> > with a different name or you can backup the database & restore it as a
> > different name. For smaller databases, you can even do the Copy database
> > wizard which can create a copy of the database with a different name.
> > Please refer to SQL Server Books Online for details on any of these
> > approaches and check the following MSKB links :
> > http://support.microsoft.com/default.aspx?kbid=314546
> > http://support.microsoft.com/defaul...scid=kb;q224071
> > --
> > - Anith
> > ( Please reply to newsgroups only )

You shouldn't lose anything if you use backup/restore or
detach/attach, as they don't make any changes within the database.
Backup/restore has the advantage that the source database is always
online during the process.

Simon

No comments:

Post a Comment