Created
January 21, 2015 11:04
-
-
Save FilipDeVos/b08790b78b75fa202bc8 to your computer and use it in GitHub Desktop.
This file contains 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
if object_id(N'p_create_backup') is null | |
exec('create procedure p_create_backup as return (-1)') | |
GO | |
alter procedure p_create_backup (@BackupPath nvarchar(266), @Database sysname) | |
as | |
declare @fileName nvarchar(266) = @Database + N'.bak' | |
, @safeDatabase nvarchar(258) = quotename(@Database) | |
, @fileFullPath nvarchar(266) = @BackupPath + @fileName | |
-- validate filepath here; too lazy atm | |
exec (N'BACKUP DATABASE ' + @safeDatabase + ' TO DISK = ''' + @fileFullPath + N'''') | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment