请教:我想根据一个标准数据库复制200个数据库,要求在visual studio中完成,本来是想先复制标准数据库,然后新建目标数据库,然后恢复标准数据库上去,可是行不通。sql语句如下:
backup database sample to disk='d:\data\backup\sample.bak' with init
CREATE DATABASE data1
RESTORE   FILELISTONLY  
  from   disk='d:\data\backup\sample.bak'  
 
restore database
data1 from
disk='d:\data\backup\sample.bak' with NORECOVERY,
move 'sample' to 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\data1.mdf',
move 'sample_log' to 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\data1_log.ldf'提示:
Server: Msg 3234, Level 16, State 2, Line 1
Logical file 'sample' is not part of database 'data1'. Use RESTORE FILELISTONLY to list the logical file names.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

解决方案 »

  1.   

    这个文件不是那个数据库的??
    Logical file 'sample' is not part of database 'data1'
      

  2.   

    200个数据库啊?这么多啊,不知道SQL能不能支持哦,等高手
      

  3.   

    restore database 
    data1 from 
    disk='d:\data\backup\sample.bak' with NORECOVERY, 
    move 'sample' to 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\data1.mdf', 
    move 'sample_log' to 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\data1_log.ldf' 
      

  4.   

    restore database 
    data1 from 
    disk='d:\data\backup\sample.bak' with NORECOVERY, 
    with move 'sample' to 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\data1.mdf', 
    move 'sample_log' to 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\data1_log.ldf'
      

  5.   

    BACKUP DATABASE Northwind 
       TO DISK = 'c:\Northwind.bak'
    RESTORE FILELISTONLY 
       FROM DISK = 'c:\Northwind.bak'
    RESTORE DATABASE TestDB 
       FROM DISK = 'c:\Northwind.bak'
       WITH MOVE 'Northwind' TO 'c:\test\testdb.mdf',
       MOVE 'Northwind_log' TO 'c:\test\testdb.ldf'
    GO
    参考
      

  6.   

    Server: Msg 3101, Level 16, State 2, Line 1
    Exclusive access could not be obtained because the database is in use.
    Server: Msg 3013, Level 16, State 1, Line 1
    RESTORE DATABASE is terminating abnormally.