SQLSERVER 压缩服务器端备份文件

本文介绍了如何在SQL Server 2000和2005中压缩服务器端的数据库备份文件。在SQL2000中,通过`xp_makecab`执行压缩,而在SQL2005中,需先启用`xp_cmdshell`,然后调用`makecab.exe`进行压缩。此外,还展示了如何使用`xp_cmdshell`复制已压缩的备份文件。

一、在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).

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值