首先,如果沒有啟用xp_cmdshell,請執行以下啟用:
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
1.創建映射:
exec master..xp_cmdshell 'net use \\192.168.9.140\Share 123456 /user:192.168.9.140\administrator'
2.備份數據庫:
backup database aa to disk='\\192.168.9.140\Share\testDB.bak' with init
3.刪除備份:
exec master..xp_cmdshell 'net use \\192.168.9.140\Share /delete'