Return to Snippet

Revision: 16217
at July 29, 2009 06:31 by marcocs


Initial Code
USE [master] ;

/* PRIVATE FIELD(s) */
DECLARE @Database SYSNAME ;
DECLARE @FilePath NVARCHAR(500) ;
DECLARE @FileName NVARCHAR(500) ;
DECLARE @BackupName NVARCHAR(500) ;
DECLARE @DeviceName NVARCHAR(500);

/* FILL FIELD(s) */
SELECT  @Database = 'DATA BASE NAME'
SELECT  @FilePath = N'D:\Backup\';
SELECT  @FileName = @FilePath + @Database + '.bak' ;
SELECT  @DeviceName = @Database + '_' + 'dump';

/* CREATE BACKUP DEVICE */
IF (SELECT COUNT(*) FROM sys.backup_devices WHERE NAME=@DeviceName)<=0
BEGIN
	EXEC sp_addumpdevice 'disk', @DeviceName, @FileName;
END

/* BACKUP DATABASE */
BACKUP DATABASE @Database TO @DeviceName
GO

Initial URL

                                

Initial Description
Crear un backup de una base de datos en SQL Server 2005/08 desde código en la posición definida por Device.

Cuidado con los permisos:
http://support.microsoft.com/kb/207187/es

Initial Title
Full Backup Script With Device

Initial Tags
backup

Initial Language
SQL