declare@dirvarchar(256),@dir_dbvarchar(256),
@verbvarchar(256),@cmdvarchar(256),
@backup_namevarchar(256),@dynamic_namevarchar(10),
@disk_namevarchar(256)
--建立网络连接
execxp_cmdshell'netuseK:/delete'
execxp_cmdshell'netuseK:Lantbackupbackup/user:Lantbackup'
--设定名字
set@dynamic_name=convert(varchar(10),getdate(),120)
set@dir='K:'+@dynamic_name
set@dir_db=@dir+'ibm'
set@verb='mkdir'
--建立目录
--set@cmd=@verb+@dir
--execxp_cmdshell@cmd
set@cmd=@verb+@dir_db
execxp_cmdshell@cmd
--wapec_wap
set@backup_name='lifengOA_'+@dynamic_name
set@disk_name=@dir_db+''+@backup_name
EXECsp_addumpdevice'disk',@backup_name,@disk_name
BACKUPDATABASEec_wapTO@backup_name
execsp_dropdevice@backup_name
--文档ec_tech
set@backup_name='文档_'+@dynamic_name
set@disk_name=@dir_db+''+@backup_name
EXECsp_addumpdevice'disk',@backup_name,@disk_name
BACKUPDATABASEec_techTO@backup_name
execsp_dropdevice@backup_name
--博吧ec_blog
set@backup_name='博吧_'+@dynamic_name
set@disk_name=@dir_db+''+@backup_name
EXECsp_addumpdevice'disk',@backup_name,@disk_name
BACKUPDATABASEec_blogTO@backup_name
execsp_dropdevice@backup_name
execxp_cmdshell'netuseK:/delete'
然后做一个Task,那么,SQLServer就会备份到指定的网络地址Lantbakcup下