public boolean bankUpDataBase(String filePath) throws Exception{
      DBManager db = DBManager.getInstance();
      String qrySQL = " USE master select Count(phyname) from   master..sysdevices   where   name= \'backupBank\'  ";
      ResultSet rs =  db.executeQuery(qrySQL);
      if (rs.getInt(0)>0){
       String sql = "USE master exec sp_dropdevice \'backupBank\' ";
       PreparedStatement pstmt = db.getCon().prepareStatement(sql);
      String SQL = "USE master  "+
                   "EXEC sp_addumpdevice \'disk\', \'backupBank\',\'"+ filePath+ "\'  "+
                   "BACKUP DATABASE bank TO backupBank ";
      PreparedStatement pstmt = db.getCon().prepareStatement(SQL);
     }catch (Exception e){
      return false;
     return true;

USE master

 EXEC sp_addumpdevice 'disk', 'backupBank','d:\backup\bank.dat'

 BACKUP DATABASE bank TO backupBank

USE master
select Count(phyname)   from   master..sysdevices   where   name= 'backupBank'

USE master
exec sp_dropdevice 'backupBank'

作者: ﹎"該變ゾ   发布时间: 2011-06-15