Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#352606 - 08/06/2012 11:58 SQL restore issue
tahir
pooh-bah

Registered: 27/02/2004
Posts: 1914
Loc: London
I need to restore a backup of an SQLSERVER database (Ac_Fli) to a different db (Ac_Trn). Using the SQL Management Studio restore tool has given me the following script:

RESTORE DATABASE [Ac_Trn]
FROM DISK = N'\\SQLSERVER\Backups\Ac_Fli.bak'
WITH FILE = 1,
MOVE N'AC_Fli_Data' TO N'C:\SQL DATA\ASL\Ac_Trn.mdf',
MOVE N'AC_Fli_Log' TO N'C:\SQL DATA\ASL\Ac_Trn_log.ldf',
NOUNLOAD, REPLACE, STATS = 10
GO

I think it should be:

RESTORE DATABASE [Ac_Trn]
FROM DISK = N'\\SQLSERVER\Backups\Ac_Fli.bak'
WITH FILE = 1,
MOVE N'AC_Trn_Data' TO N'C:\SQL DATA\ASL\Ac_Trn.mdf',
MOVE N'AC_Trn_Log' TO N'C:\SQL DATA\ASL\Ac_Trn_log.ldf',
NOUNLOAD, REPLACE, STATS = 10
GO

Which version is right?

Top
#352612 - 08/06/2012 17:20 Re: SQL restore issue [Re: tahir]
tanstaafl.
carpal tunnel

Registered: 08/07/1999
Posts: 5549
Loc: Ajijic, Mexico
Originally Posted By: tahir
Which version is right?
First of all, don't give a lot of credence to my reply. I know almost nothing about SQL. But...

In the unlikely event that I understand what you are doing here, it seems as though you are trying to overwrite the existing Ac_Trn.mdf file with data from the N'AC_Fli_Data backup. So it makes sense that you would

MOVE N'AC_Fli_Data' TO N'C:\SQL DATA\ASL\Ac_Trn.mdf',
MOVE N'AC_Fli_Log' TO N'C:\SQL DATA\ASL\Ac_Trn_log.ldf',

so I would go with the first version, the one that SQL Management Studio gave you.

Keep in mind that this is ignorance and guesswork speaking!

tanstaafl.
_________________________
"There Ain't No Such Thing As A Free Lunch"

Top
#352661 - 12/06/2012 09:10 Re: SQL restore issue [Re: tanstaafl.]
tahir
pooh-bah

Registered: 27/02/2004
Posts: 1914
Loc: London
Yes. The bit that threw me was that the logical name had been set incorrectly so when I tried to run the command it kept failing. Fixed the logical names and now it works, thanks.

Top