There is often a need to back up the database regularly. Scheduled backup to the local, or is quite easy, the scheduled task can be completed, but if the machine is hung, the backup to the machine is meaningless, then need to consider the backup to the LAN, other computers.
Below to share a copy on the Internet after the simple collation of the code, with SQL Server agent in the job function, has been running stably for one weeks, the hourly backup.
--Create a network map (y is the drive letter; the name of the shared folder after the IP address; password is the password, double quotation marks; account is the login name of the remote computer) exec master. xp_cmdshell ' net use Y: \\192.168.0.69\sqlbackup "password"/user:192.168.0.69\account '--file name by date time (note the folder in the path, Need to be established first) declare @filename varchar () Select @filename = ' Y:\DB\ ' + replace (replace (varchar, GETDATE (), (), '-', '), ' ', '-'), ': ', ') + '. Bak '--Perform a backup (db is the name of the database to be backed up) backup database [db] to disk = @filename--delete network map (y is drive letter, IBID.) exec Master.. xp_cmdshell ' net use Y:/delete '
This article is from the "Rain Wandering Blog" blog, please be sure to keep this source http://kingrain.blog.51cto.com/91779/1614012
SQL Server Remote Backup Database