SQL Server Backup Format


Below given codes will create a standard Backup File in the designated disk.

DECLARE @Date VARCHAR(20)
DECLARE @Name VARCHAR(256)
DECLARE @File varchar(256)
DECLARE @Test varchar(256)

SET @Date = GETDATE()
SET @Name = ‘FullBackup’
set @Test = ‘D:\’
SELECT @Date = CONVERT(VARCHAR(20),GETDATE(),112)+ ‘_’+
REPLACE(CONVERT(VARCHAR(20),GETDATE(),108),’:’,”)
SET @File = @Test + @Name + ‘_’+ @Date + ‘.BAK’

BACKUP DATABASE Testing TO DISK = @File WITH STATS, COMPRESSION, CHECKSUM;

*Sushil Rout*
*Sr. Database Administrator*

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: