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

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

被折叠的 条评论
为什么被折叠?



