Hi
I would like to creat a job in MS SQL Server 2000 to do the following:
1. Drop Test_DB
2. Restore Current_DB (latest backup in my_dir) as Test_DB
Can anyone help me on this? I think it is a simple as
--start code
DROP DATABASE Test_DB
GO
RESTORE DATABASE Test_DB
FROM Current_DB ?
GO
--end code
It is the second line that bothers me. I want to restore the most
recent backup of Current_DB. How can I get and specify this info?
Also, when I use EM to restore it gives me the option to rename the
files, can I specify this too?
thanks
dabenTry something like:
RESTORE DATABASE Test_DB
FROM DISK='C:\My_Dir\Current_DB.bak'
WITH
MOVE 'Current_DB' TO 'E:\DataFiles\Test_DB.mdf',
MOVE 'Current_DB_Log' TO 'C:\LogFiles\Test_DB_Log.ldf',
REPLACE
GO
You find the names log the logical files for the above command with
RESTORE FILELISTONLY:
RESTORE FILELISTONLY
FROM DISK='C:\MyDir\Current_DB.bak'
GO
See RESTORE in the Books Online for more information.
--
Hope this helps.
Dan Guzman
SQL Server MVP
--
SQL FAQ links (courtesy Neil Pike):
http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
--
"daben" <dabenpb@.yahoo.com> wrote in message
news:1adbeff3.0309111224.1fe1b9ac@.posting.google.com...
> Hi
> I would like to creat a job in MS SQL Server 2000 to do the following:
> 1. Drop Test_DB
> 2. Restore Current_DB (latest backup in my_dir) as Test_DB
> Can anyone help me on this? I think it is a simple as
> --start code
> DROP DATABASE Test_DB
> GO
> RESTORE DATABASE Test_DB
> FROM Current_DB ?
> GO
> --end code
> It is the second line that bothers me. I want to restore the most
> recent backup of Current_DB. How can I get and specify this info?
> Also, when I use EM to restore it gives me the option to rename the
> files, can I specify this too?
> thanks
> daben
Showing posts with label tsql. Show all posts
Showing posts with label tsql. Show all posts
Wednesday, March 28, 2012
Wednesday, March 7, 2012
restore MSSQL BAK file by TSQL
Hi,
I need an application with asp.net that let me restore database by getting .bak file and database name and database user and user password, my database is SQL Server 2005.
There is an open source one named
Database Publishing Services 1.1
Google it or search Microsoft site about it
HTH
Regards
Subscribe to:
Posts (Atom)