SQL Server Heterogeneous Backup

Source: Internet
Author: User
Tags getdate

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.