Re: When to use Move with Restore in T-SQL

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Steve Z (szlamany_at_antarescomputing_no_spam.com)
Date: 05/10/04


Date: Mon, 10 May 2004 16:34:20 -0400

We use many variations of the following, which we got right out of BOL. The
two lines that are commented out do a BACKUP - and the two that are not,
restore it, in this case to a different "DATABASE NAME".

--BACKUP DATABASE Funds
-- TO DISK = 'c:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\Funds_NB_Jun30.bak'
RESTORE FILELISTONLY
   FROM DISK = 'c:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\Funds_NB_Jun30.bak'
RESTORE DATABASE Funds_NB_Jun30
   FROM DISK = 'c:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\Funds_NB_Jun30.bak'
   WITH MOVE 'Funds_data' TO 'c:\Program Files\Microsoft SQL
Server\MSSQL\Data\Funds_NB_Jun30.mdf',
   MOVE 'Funds_log' TO 'c:\Program Files\Microsoft SQL
Server\MSSQL\Data\Funds_NB_Jun30.ldf'
GO

"Bumpy Brown" <anonymous@discussions.microsoft.com> wrote in message
news:2329236F-D58B-457C-B10C-B4533BDE7FF8@microsoft.com...
>
> In the example, my "SERVER_B" does not have a drive H, and the
directory structure is different, yet the RESTORE works without specifying
the WITH MOVE option. Am I missing something here?
>
> ----- Keith Kratochvil wrote: -----
>
> Lets say that SERVER_A has its' mdf files on drive K and it's ldf
files on L.
> SERVER_B does not have K and L drives. If you tried to restore a
database from SERVER_A to SERVER_B by using the T-SQL RESTORE command the
process would return an error because drives K and L do not exist. In this
case you will have to specify WITH MOVE... in order to move the mdf and ldf
file(s) to a new location during the restore.
>
> --
> Keith
>
>
> "Bumpy Brown" <anonymous@discussions.microsoft.com> wrote in message
news:1484A506-0A8E-490A-A6A1-C761BB982DA2@microsoft.com...
> > I'm attempting to do some automation of database restores. These
are backups generated on a different server, which I am restoring to my
local machine using T-sql rather than E.M. for speed reasons. My question
is, when exactly do I have to use the "WITH MOVE" option in my restore
script? The documentation states that MOVE must be used when the location
is different, yet I am able to restore "H:\Data\Doodah_Data.mdf" to
"C:\MSSQL\Data\Doodah_Data.mdf" without error. Therefore I surmise that
"location" does not refer to the path, but perhaps to the filename itself?
I'd like this utility to work on other folks' machines, so I can't just get
it to work on mine and call it a day.
> >> Thank you.
> >



Relevant Pages

  • RE: How do I restore from mdf and ldf files?
    ... Tasks -> Backup Database ... Tasks -> Restore Database ... Windows 2003 Server with Latest Service Pack ... Pre-requisites for Sharepoint Backup and Restore: ...
    (microsoft.public.sharepoint.portalserver)
  • Re: Restoring SQL Server Backups
    ... ORIGINAL BACKUP & RESTORE (MSDE Database) ... occurrenceof cachestore flush for the 'Object Plans' cachestore (part ...
    (microsoft.public.sqlserver.server)
  • Re: Restoring SQL Server Backups
    ... ORIGINAL BACKUP & RESTORE (MSDE Database) ... occurrenceof cachestore flush for the 'Object Plans' cachestore (part ...
    (microsoft.public.sqlserver.server)
  • Re: POINT IN TIME RESTORE
    ... This is what you should have done in order to do the restore as you wish: ... > 3- erase data ... > 5- restore database with norecovery ... The BACKUP DATABAE can of course be at an earlier point in time, ...
    (microsoft.public.sqlserver.server)
  • Re: Migration ?
    ... I've tried every way I can think of trying to restore the master database. ... Will a restore on the SQL ... Install a SQL Server failover cluster instance ...
    (microsoft.public.sqlserver.clustering)