SQLSERVER 压缩服务器端备份文件

来源:互联网 发布:淘宝网订单号查询 编辑:程序博客网 时间:2024/05/17 00:54

一、在SQL2000当中

   use master

  backup database zy to disk='C:/db.bak' with noinit  --备份

  use master exec xp_makecab 'c:/db.cab',mszip,1,'c:/db.bak'     --mszip 压缩方式

二、在SQL2005当中

  首先在SQLSERVER 外围应用配置器中启用xp_cmdshell.

  use master

  exec xp_cmdshell "makecab c:/db.bak  d:/db.cab"  --调用系统命令 makecab

三、复制文件

    exec xp_cmdshell "copy d:/db.cab f:/db.cab"

----------------------------原形--------------------------------------

用   xp_cmdshell   调用system32下的makecab.exe可以压缩文件

使用方法:命令行下输入命令

MAKECAB   [/V[n]]   [/D   var=value   ...]   [/L   dir]   source   [destination]
MAKECAB   [/V[n]]   [/D   var=value   ...]   /F   directive_file   [...]

    source                   File   to   compress.
    destination         File   name   to   give   compressed   file.     If   omitted,   the
                                  last   character   of   the   source   file   name   is   replaced
                                  with   an   underscore   (_)   and   used   as   the   destination.
    /F   directives     A   file   with   MakeCAB   directives   (may   be   repeated).
    /D   var=value       Defines   variable   with   specified   value.
    /L   dir                   Location   to   place   destination   (default   is   current   directory).
    /V[n]                     Verbosity   level   (1..3).

 

原创粉丝点击