Regular backups of the SQL Server database are often required. Regular backup to this machine, or quite easy, planning tasks can be completed, but if the machine is hung, that backup to this machine is meaningless, then you need to consider backup to the local area network, other computers.
The following is a share of a search on the internet after the simple collation of their own code, with the SQL Server agent in the job function, has been stable operation for one weeks, every hour on the backup.
Copy Code code as follows:
--Create a network map (y is the letter; the name of the shared folder after the IP address; password is the password, double quotes; account is the remote computer's login name)
EXEC master.. xp_cmdshell ' net use Y: \\192.168.0.69\sqlbackup ' password '/user:192.168.0.69\account '
--By date Time file name (note the folder in the path, you need to first set up)
DECLARE @filename varchar (200)
Select @filename = ' Y:\DB\ ' + replace (replace (CONVERT (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 the letter, IBID.)
EXEC master.. xp_cmdshell ' net use Y:/delete '