Two methods are provided here:
1. Write the stored procedure and create a scheduled job backup.
-- Ing in SQL
Exec master.. xp_mongoshell 'net use Z: \ computer_name \ D $ "password"/User: computer_name \ Administrator'
/* -- Description:
Z: indicates the drive letter of the local machine corresponding to the ing network path, which corresponds to the following Backup
\ Computer_name \ D $ is the network path to be mapped
Computer_name is the name of a remote computer,
Administrator is the Login User Name
Password of the specified administrator user
--*/
-- Backup; with init overwrite ¦ noinit to add
Backup database name to disk = 'e: \ h_backup.bak 'with init
-- Copy
Exec master .. xp_mongoshell 'Copy E: \ h_backup.bak Z :'
-- Delete (this sentence can be removed)
-- Exec master .. xp_mongoshell 'del E: \ h_backup.bak'
-- Delete the ing after the ing is completed
Exec master.. xp_mongoshell 'net use Z:/delete'
2. Scheduling
Enterprise Manager -- manage -- SQL Server proxy -- Right-click a job -- create a job -- enter the job name in "general" -- "Step" -- create -- "Step name" and enter the step name in "Step name -- select "Transact-SQL script (tsql)" from "type) "--" Database "select the database for command execution --" command "and enter the statement to be executed:
Declare @ strsql varchar (1000)
Declare @ strdirname varchar (50)
Declare @ strcmd varchar (50)
Declare @ strsend varchar (1000)
Declare @ strdate varchar (50)
Exec master.. xp_mongoshell 'net use \ 192.168.0.151 \ D $ password/User: 192.168.0.151 \ Administrator'
Set @ strsql = 'backup database new_his to disk = ''\ 192.168.0.151 \ D $ \ serverd \'
Set @ strdirname = Replace (substring (convert (varchar (20), getdate (), 120),), '-', '') + '12'
Set @ strcmd = 'md \ 192.168.0.151 \ D $ \ serverd \'s
Et @ strcmd = @ strcmd + @ strdirname
Exec master .. xp_mongoshell @ strcmd
-- Print @ strsql
Set @ strsql = @ strsql + @ strdirname + '\ new_hisbackup.dat' with init, nounload, noskip, noformat '-
-Print @ strsql
Exec (@ strsql)
---- The IP addresses and shared directories written here are modified by the netizens themselves, password must be correct -- OK -- "scheduling" item -- create scheduling -- enter the scheduling name in "name" -- select your job execution schedule in "scheduling type" -- if "appears repeatedly ""-- click" change "to set your schedule and start the SQL Agent service, and set it to automatic start. Otherwise, your job will not be executed as follows: my computer -- control panel -- Administrative Tools -- service -- Right-click SQLServerAgent -- properties -- start type -- select "auto start" -- OK.