Copy Code code as follows:
Use master
DECLARE @dir varchar (256), @dir_db varchar (256),
@verb varchar (256), @cmd varchar (256),
@backup_name varchar (256), @dynamic_name varchar (10),
@disk_name varchar (256)
--Establish a network connection
EXEC xp_cmdshell ' net use K:/delete '
EXEC xp_cmdshell ' net use K: \\Lant\backup backup/user:lant\backup '
--Set name
Set @dynamic_name =convert (varchar), GETDATE (), 120)
Set @dir = ' k:\ ' + @dynamic_name
Set @dir_db = @dir + ' IBM '
Set @verb = ' mkdir '
--Create a directory
--set @cmd = @verb + @dir
--exec xp_cmdshell @cmd
Set @cmd = @verb + @dir_db
EXEC xp_cmdshell @cmd
--wap Ec_wap
Set @backup_name = ' Lifengoa_ ' + @dynamic_name
Set @disk_name = @dir_db + ' + ' + @backup_name
EXEC sp_addumpdevice ' disk ', @backup_name, @disk_name
BACKUP DATABASE Ec_wap to @backup_name
EXEC sp_dropdevice @backup_name
--Document Ec_tech
Set @backup_name = ' Document _ ' + @dynamic_name
Set @disk_name = @dir_db + ' + ' + @backup_name
EXEC sp_addumpdevice ' disk ', @backup_name, @disk_name
BACKUP DATABASE Ec_tech to @backup_name
EXEC sp_dropdevice @backup_name
--Bo Bar Ec_blog
Set @backup_name = ' Bo bar _ ' + @dynamic_name
Set @disk_name = @dir_db + ' + ' + @backup_name
EXEC sp_addumpdevice ' disk ', @backup_name, @disk_name
BACKUP DATABASE Ec_blog to @backup_name
EXEC sp_dropdevice @backup_name
EXEC xp_cmdshell ' net use K:/delete '
Then do a task, then SQL Server will back up to the specified network address \\Lant\bakcup