Cari Blog Ini

13 Juni 2012

Backup Database Using Syntax

----------------------------------------------------
-----code:start
----------------------------------------------------
Declare
    @Backup as varchar(100)
    ,@BackupFile as varchar(100)
   
select
    @BackupFile='DB_Test'
    +'_'+ convert(varchar(20),getdate(),12)
    +'_'+ replace(CONVERT(VARCHAR(5),GETDATE(),108), ':', '')+'.dat'
   
select @Backup='C:\Backup_DBTest\'+@BackupFile

backup database [DB_Test] to DISK=@Backup
----------------------------------------------------
-----code:end
----------------------------------------------------

 
Result Messages:
Processed 160 pages for database 'DB_Test', file 'DB_Test' on file 1.
Processed 1 pages for database 'DB_Test', file 'DB_Test_log' on file 1.
BACKUP DATABASE successfully processed 161 pages in 0.366 seconds (3.436 MB/sec).