1、建立共享文件夹,并设置相应的用户权限。
2、打开Sql Server管理器,Sql Server代理,作业,新建作业。
3、脚本语句:
exec master..xp_cmdshell 'net use \\192.168.2.250\SQL\OA abcd_1234 /user:192.168.2.250\gtp'
declare @database nvarchar(50) ='defaultDB' ;
declare @date datetime = getdate();
Declare @fileName nvarchar(200) = '\\192.168.2.250\SQL\OA\'+@database + replace(Convert(nvarchar,@date,120 ) ,':','_') + '.bak'
Backup Database @database To disk = @fileName With Format
exec master..xp_cmdshell'net use \\192.168.2.250\SQL\OA /delete'