我现在正用 SQL Sever 做一管理系统(以前都是做底层的), 可是现在不知道怎么进行数据库的备份和恢复啊  !用存储过程还是用 DMO ,怎么实现 ?我真的很着急呢,请各位高手赐教 !另外还有能不能将数据直接备份到光盘上,怎么实现 ?感谢多多 !!!!!!!!

解决方案 »

  1.   

    查查backup和restore这两个SQL语句,不难的.
      

  2.   

    备份:
             CDatabase db;
    CString s1;
    s1.Format("ODBC;UID=sa;PWD=%s","wei147");
    db.Open("odbcname",false,false,s1);
    s1.Format("backup database report to disk='e:\\report.bak\\backs.dat'"); //备份到E:\report.bak\backs.dat
    db.ExecuteSQL(s1);
    恢复:
             恢复时用户不能打开要恢复的数据库
    CDatabase db1;
             s1.Format("ODBC;UID=sa;PWD=%s","wei147");
    db1.Open("odbcname",false,false,s1);
    s1.Format("restore database report from  disk='c:\\report.bak\\backs.dat'");
    db1.ExecuteSQL(s1);
    db1.Close();
    ODBC做的
      

  3.   

    SQLSERVER上面设置以下就可以了
      

  4.   

    我用了下边这个方法 ,但是还没成功,这是怎么回事啊 ???????--Create the backup device for the full MyNwind backup.
    USE masterEXEC sp_addumpdevice 'disk', 'MyTempDB_1',     'c:\mssql7\backup\MyTempDB_1.dat'-- Back up the full tempdb database.
    BACKUP DATABASE tempdb TO MyTempDB_1但是系统却给出下面的提示 :
    (1 row(s) affected)'Disk' device added.
    Server: Msg 3147, Level 16, State 1, Line 8
    Backup and restore operations are not allowed on database tempdb.
    Server: Msg 3013, Level 16, State 1, Line 8
    Backup or restore operation terminating abnormally.请高手解释一下 ,多谢 !!!!!!!
      

  5.   

    Server: Msg 3147, Level 16, State 1, Line 8
    Backup and restore operations are not allowed on database tempdb.
    备份和恢复操作不允许在tempdb数据库上。所以,你改成自己建的数据库再试试,应该可以。
    Server: Msg 3013, Level 16, State 1, Line 8
    Backup or restore operation terminating abnormally.
      

  6.   

    其实SQLSERVER自己有备份功能的,只要进行简单的设置就行了,很方便定期维护和备份,见企业管理器的 数据库维护计划