1 /*2 LANDV3 function: Different machine backup4 Development Date: July 2, 2016 15:27:085 6 */7 if exists(Select * fromDbo.sysobjectswhereId= object_id(N'[dbo]. [P_backupdb]') and ObjectProperty(ID, N'isprocedure')= 1) 8 Drop procedure [dbo].[p_backupdb] 9 GOTen Create procp_backupdb One @dbnamesysname='AIS20110306202234', A @bkpath nvarchar(260)='\\k3ser\landvback\',--exec master. xp_cmdshell ' net use \ \ computer name \ shared directory password/user: computer name \ user i ';(\ \ computer name \ shared directory \ backup file name] - @bkfname nvarchar(260)='\dbname\_backup_\date\_\time\. BAK', - @bktype nvarchar(Ten)='DB', the @appendfile bit=1 - as - Declare @sql varchar(8000) - if IsNull(@dbname,"')="' Set @dbname=db_name() + if IsNull(@bkpath,"')="' Set @bkpath="' - if IsNull(@bkfname,"')="' Set @bkfname='\dbname\_\date\_\time\. BAK' + Set @bkfname=Replace(Replace(Replace(@bkfname,'\dbname\',@dbname) A,'\date\',Convert(varchar,getdate(), the)) at,'\time\',Replace(Convert(varchar,getdate(),108),':',"')) - Set @sql='Backup'+ Case @bktype when 'LOG' Then 'Log' Else 'Database' End +@dbname - +'To disk=" "+@bkpath+@bkfname - +" " with'+ Case @bktype when 'DF' Then 'differential,' Else "' End - + Case @appendfile when 1 Then 'Noinit' Else 'INIT' End - Print @sql in exec(@sql) - Go to execP_backupdb
is too lazy to use the system comes with, set up good trouble ah, directly hit the code bar, haha
SQL Server Heterogeneous Backup