Last active
August 29, 2015 14:21
-
-
Save vaneves/e5f7fe87dca525d9db52 to your computer and use it in GitHub Desktop.
Backup SQL Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @FileName AS VARCHAR(30), @FullPath AS VARCHAR(200), @Database sysname; | |
SET @Database = 'MyDatabaseName'; | |
SET @FileName = CONVERT(VARCHAR(30), GETDATE(), 20); | |
SET @FileName = REPLACE(@FileName, '-', ''); | |
SET @FileName = REPLACE(@FileName, ' ', ''); | |
SET @FileName = REPLACE(@FileName, ':', ''); | |
SET @FileName = @Database + '_' + @FileName + '.bak'; | |
SET @FullPath = 'C:\MyBackups\Path\' + @FileName; | |
BACKUP DATABASE @Database TO DISK = @FullPath; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment