Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Copys of original db

Author  Topic 

purisqlserver
Yak Posting Veteran

73 Posts

Posted - 2003-05-27 : 10:00:49
Hi,

I am trying to copy a datbase on the same server with different name.
(the original db has tables with data)

For this purpose, used restore command, for restoring the original db
to a different db.
But two thing are happening here:
1)the logical files names are the same for all the copy dbs.
2) the same log file from original is replicated along.(size)

is there a option to change the logical files names on making a copy.
if someone has a better option for making copies of db on the same server, let me know.


thanx......

JCamburn
Starting Member

31 Posts

Posted - 2003-05-27 : 11:24:04
You can change the logical name of the files in a database with the following syntax:


ALTER DATABASE
DatabaseName
MODIFY FILE
(
NAME = LogicalFileName,
NEWNAME = NewLogicalFileName
)


You will need to do this with both the data file and the log file.

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-05-27 : 12:33:11
You need to use the WITH MOVE option in your RESTORE command.

RESTORE DATABASE DB2
FROM DISK = 'F:\MSSQL\BACKUP\DB1.bak'
WITH MOVE 'DB1' TO 'F:\MSSQL\Data\DB2.mdf',
MOVE 'DB1_Log' TO 'F:\MSSQL\Data\DB2_Log.ldf',
REPLACE

Tara
Go to Top of Page
   

- Advertisement -