--backup Use [DBName] Declare @FullFileName Varchar(200) Declare @FileFlag varchar(20) Set @FileFlag=‘20‘+convert(char(6),getdate(),12) Set @FullFileName=‘d:\BackUp\‘+@FileFlag+‘.BAK‘ BackUp DataBase [DBName] To Disk=@FullFileName with init --restore Declare @FullFileName Varchar(200) Declare @FileFlag varchar(20) Set @FileFlag=‘20‘+convert(char(6),getdate(),12) Set @FullFileName=‘d:\BackUp\‘+@FileFlag+‘.BAK‘ RESTORE DATABASE [DBName] FROM DISK = @FullFileName WITH MOVE ‘DBName‘ TO ‘d:\SQLData\DBName.mdf‘, MOVE ‘DBName_log‘ TO ‘d:\SQLData\DBName_log.ldf‘
时间: 2024-10-26 02:43:03