Create PROCEDURE Backup_Database
AS
BEGIN
declare @Database nvarchar(256),@Path nvarchar(2048)
select @Database=N'ciTreat',@Path=N'E:/ciTreat_backup/'
declare @sql nvarchar(max)
select @sql =N'BACKUP DATABASE '+@Database+N'
TO DISK = '''+@Path+@Database+N'_'+REPLACE(REPLACE(REPLACE(convert(nvarchar(30),getdate(),126),'-','_'),':','_'),'.','_')+N'.bak''
WITH
NOFORMAT,
INIT,
NAME = N''Full Database Backup'',
SKIP'
exec xp_create_subdir N'E:/ciTreat_backup';
exec (@sql)

这里代码会在本地E盘创建一个文件地址

并把指定数据库备份到这文件地址