Friday, February 24, 2012

changing logical file names

Using SS2000 SP4. I want to create a new test database from an existing
database backup. This is the sql that I use:
RESTORE DATABASE SMC_Test
FROM disk = '\\Depts\Technology\SQLServer\Backups\Co
lu\SMS\smc_936.bak'
WITH RECOVERY,
MOVE 'SMC_Data' TO 'S:\SQL\Data\SMCLMS_Test_Data.mdf',
MOVE 'SMC_Log' TO 'L:\SQL\Logs\SMCLMS_Test_Log.ldf'
Is there a way to change the logical file names at the same time? In another
post I saw this sql:
USE master
go
ALTER DATABASE XXX MODIFY FILE
( NAME='XX_old Name',NEWNAME='XX_New Name' )
go
Do I have to run that after I restore the database or is there another way?
Thanks,
--
Dan D.You have to do it after the restore.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Dan D." <DanD@.discussions.microsoft.com> wrote in message
news:1A8C3983-25E6-4762-A6D6-3C78BCC89114@.microsoft.com...
> Using SS2000 SP4. I want to create a new test database from an existing
> database backup. This is the sql that I use:
> RESTORE DATABASE SMC_Test
> FROM disk = '\\Depts\Technology\SQLServer\Backups\Co
lu\SMS\smc_936.bak'
> WITH RECOVERY,
> MOVE 'SMC_Data' TO 'S:\SQL\Data\SMCLMS_Test_Data.mdf',
> MOVE 'SMC_Log' TO 'L:\SQL\Logs\SMCLMS_Test_Log.ldf'
> Is there a way to change the logical file names at the same time? In anoth
er
> post I saw this sql:
> USE master
> go
> ALTER DATABASE XXX MODIFY FILE
> ( NAME='XX_old Name',NEWNAME='XX_New Name' )
> go
> Do I have to run that after I restore the database or is there another way
?
> Thanks,
> --
> Dan D.|||Thanks.
--
Dan D.
"Tibor Karaszi" wrote:

> You have to do it after the restore.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Dan D." <DanD@.discussions.microsoft.com> wrote in message
> news:1A8C3983-25E6-4762-A6D6-3C78BCC89114@.microsoft.com...
>
>

No comments:

Post a Comment