For SQL Server 6.5 information, see DUMP Statement in What's New for SQL Server 6.5.
Makes a backup copy of a database and its transaction log (DUMP DATABASE) or makes a copy of only the transaction log (DUMP TRANSACTION) in a form that can be read into SQL Server using the LOAD statement.
Dumping a database:
DUMP DATABASE {dbname | @dbname_var}
TO dump_device [, dump_device2 [..., dump_device32]]
[WITH options
[[,] STATS [ = percentage]]]
Dumping a transaction log:
DUMP TRANSACTION {dbname | @dbname_var}
[TO dump_device [, dump_device2 [..., dump_device32]]]
[WITH {TRUNCATE_ONLY | NO_LOG | NO_TRUNCATE}
{options}]
where
Note The UNLOAD and NOUNLOAD options are supported only by TAPE dump devices.
When you specify a PIPE dump device, multivolume dumps and dump device options (UNLOAD, NOUNLOAD, INIT, NOINIT, SKIP, NOSKIP, EXPIREDATE, and RETAINDAYS) are not supported.
If the transaction log is on the same device as the database, using DUMP DATABASE is the only way you can create a backup copy of both the database and its transaction log. However, because DUMP DATABASE does not remove the inactive portion of the log, you must use DUMP TRANSACTION WITH TRUNCATE_ONLY to purge the log of completed transactions. Generally, databases and transaction logs should be stored on different devices; this improves performance and enables unrestricted use of both the DUMP DATABASE and DUMP TRANSACTION statements.
Note If dumping the transaction log doesn't appear to truncate the majority of your transaction log, you may have an open transaction in the log. To determine whether a transaction has been left open, use DBCC OPENTRAN.
For databases that store the data portion of the database on a separate device from the log portion, log space can be monitored with various DBCC commands and the Performance Monitor. For details, see the DBCC statement.
Prior to backing up a database, it is useful to dump a transaction log using the TRUNCATE_ONLY option to clear out the log and decrease the total time required to back up the database.
Note After dumping a transaction log using the TRUNCATE_ONLY option, you should immediately make a backup of the database using DUMP DATABASE. Dumping of the transaction log (using DUMP TRANSACTION) will not be allowed until a full database dump (using DUMP DATABASE) has been performed.
If the transaction log of a published (replicated) database becomes full and absolutely must be truncated, unsubscribe all subscriptions to the publications of that database. This allows you to truncate past the oldest distributed transaction.
After the transaction log has been dumped using NO_LOG, the changes recorded in the log are not recoverable. For recovery purposes, immediately execute the DUMP DATABASE statement.
Because both options clear the log without making a backup of it, it is unnecessary to use both the TRUNCATE_ONLY and NO_LOG option in the same statement.
The NO_TRUNCATE option provides up-to-the-minute media recovery when the master database and the log portion of the user database reside on undamaged database devices and when only the data portion of the user database is damaged.
Allows backups directly to temporary dump devices. These devices are created (or accessed, if they already exist) when the dump occurs; they do not have entries in the sysdevices system table. With DISK, TAPE, and FLOPPY specify the complete path and filename of the device. With PIPE, specify the name of the named pipe that will be used by the client application. If supplied as a variable (@temp_dump_device_var), the temporary dump device name can be specified as a string or as a char or varchar variable. If you are using a network server with a UNC name or using a redirected drive letter, specify a device type of DISK.
Important When specifying a striped dump, logical device names (or variables) and temporary device names (or variables) can be mixed. PIPE devices have been added to allow third-party vendors a flexible and powerful way to connect their own software. For typical Transact-SQL use, the PIPE device will not be used.
Note When specified, SKIP and NOSKIP override the setting as defined with the dump device (when the sp_addumpdevice system stored procedure was executed).
Important EXPIREDATE and RETAINDAYS override the configuration value for media retention when specified with the DUMP DATABASE or DUMP TRANSACTION statements. These options are used with DISK and TAPE devices only. If an expiration date is needed for diskette devices, configure media retention with the sp_configure system stored procedure.
If EXPIREDATE or RETAINDAYS is specified, subsequent dumps can be appended to that device; however, EXPIREDATE and RETAINDAYS are valid only for dumps specified with INIT.
These options only prevent SQL Server from overwriting a device. Tapes can still be erased using other methods, and disk-device files can still be deleted through the operating system.
In earlier releases of SQL Server, dumping a database or a transaction log to a single device always overwrote the previous dump unless (for tape devices only) NOINIT was specified. With SQL Server 6.0, database or transaction log dumps can be appended to any DISK or TAPE device, allowing you to keep a database and its transaction logs all within one physical location.
The SQL Server dump is a dynamic dump ¾ it can take place while the database is active. The dump captures the state of the data as it is at the moment the statement is executed; no partial transactions are reflected. Any data changes made after the dump begins are not reflected in the dumped database. Performing a dump can slow the system down somewhat, so you may want to run it when the database or table is not being heavily updated.
Ownership and permissions problems on the physical file can interfere with a DUMP statement. The sp_addumpdevice system stored procedure adds the device to the system tables, but it does not check file access permission.
You cannot execute the DUMP TRANSACTION statement while the trunc. log on chkpt. database option is enabled. Nor can you execute it after enabling select into/bulkcopy and making unlogged changes to the database with SELECT INTO or a bulk-copy operation. Use DUMP DATABASE instead.