osql - restore database

osql - restore database

Post by Q2FybG9zIE » Thu, 17 Mar 2005 19:59:04


Please help,

Using OSQL
How can I restore into a database called ydb1from a backup of database
ydb2

Tanks
 
 
 

osql - restore database

Post by Andrea Mon » Thu, 17 Mar 2005 20:24:52

hi Carlos,


you have to modify the database name to the new name..
and of course specify a different file system location for the physical
files or you will overwrite the original mydb1 files..
following you can see a statement that restores to pubs2 the pubs database
backup, moving the datafile and the transaction log file to new physical
files..

RESTORE DATABASE [pubs2] FROM DISK = N'C:\Programmi\Microsoft SQL
Server\MSSQL\BACKUP\pubs.bak'
WITH FILE = 1,
NOUNLOAD ,
STATS = 10,
RECOVERY ,
MOVE N'pubs' TO N'C:\Programmi\Microsoft SQL
Server\MSSQL\data\pubs_2.mdf',
MOVE N'pubs_log' TO N'C:\Programmi\Microsoft SQL
Server\MSSQL\data\pubs_log_2.ldf'

please have a look at
http://www.yqcomputer.com/
for RESTORE statement synopsis
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.yqcomputer.com/ ://italy.mvps.org
DbaMgr2k ver 0.10.0 - DbaMgr ver 0.56.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
--------- remove DMO to reply