标题: MSSQL网站制作之备份服务器端SQL SERVER数据库至当地目... [打印本页] 作者: 萌萌妈妈 时间: 2015-1-16 22:21 标题: MSSQL网站制作之备份服务器端SQL SERVER数据库至当地目... MyISAMMysql的默认数据库,最为常用。拥有较高的插入,查询速度,但不支持事务server|备份|服务器|数据|数据库/*浞荽^程*/
/**//*撑持服掌浞帘镜C器上*/
--
CREATEPROCEDUREup_dbbackup
(
@backup_db_nameVARCHAR(128),
@filenameVARCHAR(128),/**//*浞萋+文件名*/
@flagVARCHAR(60)OUTPUT
)
AS
SETNOCOUNTON
DECLARE@sqlNVARCHAR(4000),@parNVARCHAR(1000)
IFNOTEXISTS(
SELECT*FROMmaster..sysdatabases
WHEREname=@backup_db_name
)
BEGIN
SELECT@flag=+@backup_db_name+不存在!
RETURN
END
ELSE
BEGIN
IFRIGHT(@filename,1)ANDCHARINDEX(,@filename)0
BEGIN
/**//*定x苏I*/
DECLARE@lFlagINT
EXECUTE@lFlag=master..xp_cmdshellDIRZ:
IF@lFlag0
BEGIN
/**//*在客C192.168.2.45上创建一完整共享目db,指定一用裘兔艽a.Win98用舨恍枰裘兔艽a*/
EXECUTE@lFlag=master..xp_cmdshellNETUSEZ:192.168.2.45db$test/user:ca.atc est
IF@lFlag0
BEGIN
SELECT@flag=服掌建目掉!
RETURN
END
END
SELECT@par=@filenameVARCHAR(1000)
SELECT@sql=BACKUPDATABASE+@backup_db_name+TODISK=@filenameWITHINIT
EXECUTEsp_executesql@sql,@par,@filename
EXECUTEmaster..xp_cmdshellNETUSEZ:/DELETE
SELECT@flag=+@backup_db_name+浞莩晒!
RETURN
END
ELSE
BEGIN
SELECT@flag=浞萋e`!
RETURN
END
END