我想做个数据备份和恢复的程序,谁能把关于它的代码给我看看(sql语句怎么写)?
谢谢

解决方案 »

  1.   

    备份
    backup database tour  to disk='d:\back1.bak'
      

  2.   

    还原
    RESTORE DATABASE tour from disk='d:\back1.bak'注tour是数据库名。
      

  3.   

    我用的是MS SQL2000,恢复的时候它有错误提示,说数据库正在使用,不能执行RESTORE操作。这个问题怎么解决啊 ?
      

  4.   

    adocommand1.ConnectionString:=ConnectionString;
          With AdoCommand1 Do
            Begin
              filename:=OpenDialog1.FileName;
              CommandText:='use Master';
              Execute;
              CommandText:='Alter Database aa Set Offline with Rollback immediate';
              Execute;
              sql:='ReStore DataBase aa From Disk='''+filename+''' with replace';
              CommandText:=sql;
              Execute ;
              commandText:='alter database aa  set online with rollback immediate';
              Execute;
            End;
    其中aa 为数据库名