Monday, March 19, 2012

Database duplication

People,
I need some direction on how to duplicate a database (name: Fod) to another
database on the same server named FodTrain that not only has Fods data but
also the sprocs and ect. This needs to take place on a weekly basis.Hi Joseph
If can afford any downtime of the Fod database, use sp_detach_db, copy the
files, and use sp_attach_db command specifying new filenames. Please see BOL
for details. If you can't afford downtime, backup the database, and restore
to a new name using the MOVE option. Again, see BOL for full syntax details.
--
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"Joseph" <Joseph@.discussions.microsoft.com> wrote in message
news:A011179E-4B25-46CC-AF57-E8686DBA56C4@.microsoft.com...
> People,
> I need some direction on how to duplicate a database (name: Fod) to
> another
> database on the same server named FodTrain that not only has Fods data but
> also the sprocs and ect. This needs to take place on a weekly basis.
>|||One method is with backup/restore. For example:
BACKUP DATABASE Fod
TO DISK = 'C;\Backups\Fod.bak'
WITH
INIT,
STATS=10
GO
RESTORE DATABASE CopyOfFod
FROM DISK = 'C;\Backups\Fod.bak'
WITH
MOVE 'Fod' TO 'E:\DataFiles\CopyOfMyDatabase.mdf'',
MOVE 'Fod_Log' TO 'F:\LogFiles\CopyOfFod_Log.ldf'',
STATS=10
GO
Note that you may need to change the logical file names ('Fod' and
'Fod_Log') in the RESTORE command to match the actual logical file names of
the source database. After the restore, you can change the logical file
names with ALTER DATABASE to be tidy:
ALTER DATABASE CopyOfFod
MODIFY FILE(NAME='Fod', NEWNAME='CopyOfFod')
ALTER DATABASE CopyOfFod
MODIFY FILE(NAME='Fod_Log', NEWNAME='CopyOfFod_Log')
Hope this helps.
Dan Guzman
SQL Server MVP
"Joseph" <Joseph@.discussions.microsoft.com> wrote in message
news:A011179E-4B25-46CC-AF57-E8686DBA56C4@.microsoft.com...
> People,
> I need some direction on how to duplicate a database (name: Fod) to
> another
> database on the same server named FodTrain that not only has Fods data but
> also the sprocs and ect. This needs to take place on a weekly basis.
>|||You can also use DTS to copy objects.
"Joseph" wrote:

> People,
> I need some direction on how to duplicate a database (name: Fod) to anothe
r
> database on the same server named FodTrain that not only has Fods data but
> also the sprocs and ect. This needs to take place on a weekly basis.
>

No comments:

Post a Comment