?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
RESTORE DATABASE master FROM disk='d:\mssql7\backup\master_db.bak'
WITH MOVE 'master' to 'd:\mssql7\data\master.mdf',
MOVE 'mastlog' to 'd:\mssql7\data\mastlog.ldf',
REPLACE
go
USE master
go
UPDATE sysdatabases SET filename='d:\mssql7\data\tempdb.mdf' WHERE name='tempdb'
go
ALTER DATABASE tempdb MODIFY FILE (name = tempdev, filename = 'd:\mssql7\data\tempdb.mdf')
ALTER DATABASE tempdb MODIFY FILE (name = templog, filename = 'd:\mssql7\data\templog.ldf')
go
RESTORE DATABASE model FROM disk='d:\mssql7\backup\model_db.bak'
WITH MOVE 'modeldev' TO 'd:\mssql7\data\model.mdf',
MOVE 'modellog' TO 'd:\mssql7\data\modellog.ldf',
REPLACE
go
RESTORE DATABASE msdb FROM disk='d:\mssql7\backup\msdb_db.bak'
WITH MOVE 'msdbdata' TO 'd:\mssql7\data\msdbdata.mdf',
MOVE 'msdblog' TO 'd:\mssql7\data\msdblog.ldf',
REPLACE
go
???:The connection to SQL Server is broken after you restore themsdb???????:.
Thenorthwind, ??pubsdatabases:
After you restore themasterdatabase, the system table entries for thenorthwinddatabase and thepubsdatabase are changed and the two database, like all of the other
user databases, are in Suspect mode. If you want to reuse the original database
files and re-attach them to the server, you can use the following example.
Otherwise, if you want to restore a copy from backup, use themydbdatabase example that is described in step 6. Use the following
example to update the system table references for thenorthwind???????:. Thenorthwinddatabase contains one data file, Northwind.mdf, and one log file,
Northwind.ldf.
Run the following command from a command prompt to
start SQL Server:
d:\mssql7\binn\sqlservr -c -f -T3608 -T4022
In SQL Server Query Analyzer, execute the following
stored procedure to detach thenorthwind???????::
exec sp_detach_db N'northwind'
go
???:: You may receive the following message that indicates that there
is no access to physical files:
Server: Msg 947, Level
16, State 1, Line 1 Error while closing database 'Northwind' cleanly. Successfully detached database 'northwind'. DBCC execution completed. If
DBCC printed error messages, contact your system administrator.
In SQL Server Query Analyzer, use the following syntax
to attach thenorthwind???????::
exec sp_attach_db N'northwind', N'd:\mssql7\data\northwnd.mdf', N'd:\mssql7\data\northwnd.ldf'
go
Remap thepubs???????:.
Thepubsdatabase contains one data file, Pubs.mdf, and one log file,
Pubs_log.ldf. You can remap thepubsdatabase in the same way that you remapped thenorthwind???????:.
Restore themydb???????:.
Themydbdatabase contains one data file, Mydbdata.mdf, and one log file,
Mydblog.ldf, from the full database backup file, Mydb_db.bak.
In SQL Server Query Analyzer, execute the following
stored procedure to detach themydb???????::
RESTORE DATABASE mydb FROM disk='d:\mssql7\backup\mydb_db.bak'
WITH MOVE 'mydbdata' TO 'd:\mssql7\data\mydbdata.mdf',
MOVE 'mydblog' TO 'd:\mssql7\data\mydblog.ldf',
REPLACE
go