Tchater maintenant avec le support
Tchattez avec un ingénieur du support

LiteSpeed for SQL Server 8.9 - User Guide

About Backing Up/Restoring with LiteSpeed LiteSpeed User Interface Configure LiteSpeed for First Use Cloud Back Up Databases Automate Maintenance Tasks Restore Databases Restore Objects View Activity and History Use Command-Line Interface Use Extended Stored Procedures Troubleshoot LiteSpeed Review Additional Resources

xp_extractor

Converts LiteSpeed backups to native SQL Server backups.

This topic covers:

Syntax

NOTE: You can replace argument values with variables. For more information, see LiteSpeed Variables.

exec master..xp_extractor
@FileName = N'C:\Backups\backup.bkp',
@FileNumber = 1,
@Init = 1,
@MTFFile = N'C:\Backups\backup.bkp.bak'

Arguments

Tips:

  • To see the list of accepted arguments and data types for arguments, execute the following:
    exec master.dbo.<procedure_name> show_help

  • To convert the script for use with the command-line utilities, execute the following:
    exec master.dbo.<procedure_name> show_cmd, <xp_arguments>

 

@affinity

Processor affinity designates specific processors to run LiteSpeed, while not allowing LiteSpeed to run on the remaining processors.

This argument accepts decimal values and hexadecimal values. If a value begins with "0x" it is interpreted as hexadecimal. A positive 64-bit integer value translates to a binary mask where a value of 1 designates the corresponding processor to be able to run the LiteSpeed process.

NOTE: 32-bit Windows is internally limited to a 32-bit mask.

For example, you need to select processors 2, 3, and 6 for use with LiteSpeed. Number the bits from the right to left. The rightmost bit represents the first processor. Set the second, third, and sixth bits to 1 and all other bits to 0. The result is binary 100110, which is decimal 38 or hexadecimal 0x26. Review the following for additional information:

Decimal Value

Binary Bit Mask

Allow LiteSpeed Threads on Processors

0 0 All (default)

1

1

1

3

11

1 and 2

7 111 1, 2 and 3

38

100110

2, 3, and 6

205 11001101 1, 3, 4, 7, and 8

Tip: Before you start tuning the CPU Throttle or Affinity parameters to adjust backup performance, try limiting the number of threads. If you decide to use an affinity value other than default, it is recommended that you limit the threading as well. You may also want to consider using Adaptive Compression to maintain backup performance. For more information, see Adaptive Compression.

@backupfile

The name of the LiteSpeed backup device file to be extracted. This argument accepts network destinations.

For TSM backups and TSM archives, this argument accepts the following formats:

  • tsmbkp:<filespace>\<high>\<low>

  • tsmarc:<filespace>\<high>\<low>

You can supply multiple instances of this argument.

@backupindex

Specifies the particular backup to use when recasting, restoring, extracting or reading from files with multiple appended backups. You can run xp_restore_headeronly to query the files contained within the backup set given by backup_file_name.

@basesize

The smallest chunk of memory LiteSpeed attempts to write to disk at any given time.

@encryptionkey

Value used to generate the encryption key for the encryption algorithm. If you do not supply encryption key, then the program will not encrypt the backup. If you use the wrong encryption key, the restore will fail.

Caution: When encrypting data, take care not to lose the encryption key; a backup cannot be restored or recovered without the original encryption key.

Example of key: 'Mypassword'

@filename

Specifies a backup location (e.g. C:\backups\AdventureWorks.bak). This argument accepts network destinations. You can supply multiple instances of this argument to use stripe backups.

@filenumber

Disk restores:

Specifies the particular backup to use when recasting, restoring, extracting or reading from files with multiple appended backups. You can run xp_restore_headeronly to query the files contained within the backup set given by backup_file_name.

Tape restores:

Identifies the backup set to be restored. For example, a file number of 1 indicates the first backup set on the backup medium, and a file number of 2 indicates the second backup set.

@init

Disk or TSM backups

  • 0—Appends the backup to an existing backup file set. For TSM backups, it results in an error if the file object already exists.
  • 1—Re-initializes (overwrites and replaces) the target backup files. For TSM backups, this will create the TSM object and version the backup based on the retention policy.

Tape backups

  • 0—Appends the backup to tape.
  • 1—If the tape was previously formatted by LiteSpeed, it wipes out all the backups by writing at the tape's beginning.

See also @format.

NOTE: 0 is the default value if you do not provide this parameter.

@ioflag

Specifies if LiteSpeed should wait and retry the read or write operation on failure. You can define retry options using the following parameters:

  • DISK_RETRY_COUNT—Specifies the number of times that a specific operation will be retried on failure. The default is 4 retries, the maximum allowed setting is 1000.
  • DISK_RETRY_WAIT—Specifies the number of seconds to wait immediately following a failure before retrying. The default is 15 seconds, the maximum allowed setting is 300.

Note: This functionality is only available for disk and cloud operations.

@logging

Writes a log file for the operation. This argument accepts one of the following values:

  • 0—Logging off.

  • 1 or any odd value—Logging on. Log file is removed on success.

  • 2 or any even value—Logging on.

The default output directory is C:\Documents and Settings\All Users\Application Data\Quest Software\LiteSpeed\SQL Server\Logs (or C:\ProgramData\Quest Software\LiteSpeed\SQL Server\Logs) (or C:\ProgramData\Quest Software\LiteSpeed\SQL Server\Logs). To log to a different directory add @Trace='logpath=path'.

See Configure Logging in LiteSpeed for information about LiteSpeed logging.

@maxtransfersize

Specifies the largest unit of transfer in bytes to be used between SQL Server and LiteSpeed. The possible values are multiples of 65536 bytes (64 KB) ranging up to 4,194,304 bytes (4 MB). The default is 1048576 (1 MB).

@mtffile

Specify the location and name of the Microsoft Tape Format (MSTF) base file.

The extractor utility will create one backup device file for each thread used in a LiteSpeed backup.

The extracted files containing the native SQL Server backup will have the following format: base_file_namex.

Where:

  • base_file_name is the specified Microsoft Tape Format base file.
  • x is a number or letter that represents the sequence of the files. In case there are no additional files, the base file will not have an x appended to its name.

NoteS:

  • You can specify a network destination for this parameter.
  • You only need to specify this parameter once. The extraction utility will create all the necessary files automatically.

  • You cannot tell the extraction utility to extract a different number of native SQL Server files. However, you can specify different destinations for the extracted files by supplying a file name with the -E parameter for each of the native SQL Server files. To see how many files extractor.exe will create, run it without this parameter. See example 4 for more information.
  • If a full path is not specified, the extracted files will be created in the current directory.

@priority

Specifies the priority of the LiteSpeed process compared to other processes running on the same server. This argument accepts one of the following values:

  • -1—Below Normal

  • 0—Normal (Default)

  • 1—AboveNormal

  • 2—High

@showhelp

Displays the syntax summary of the LiteSpeed command-line utility.

@throttle

Specifies the maximum CPU usage allowed. The argument accepts an integer value between 1 and 100. The default value is 100. This is the percentage of the total amount of CPU usage (across all enabled processors) available.

@trace

Used by LiteSpeed to activate trace logging.

@tsmarchive

Specifies to store the backup as a TSM archive. This argument accepts one of the following values:

  • 0—False (default)
  • 1—True

@tsmfile

Specifies the TSM file.

@tsmclientnode

Specifies the TSM server LiteSpeed connects to during backups and restores. Not required, if specified in the options file or if backing up with the Passwordaccess Generate option.

@tsmclientownerpwd

Specifies the TSM client owner user password. Not required, if specified in the options file or if backing up with the Passwordaccess Generate option.

@tsmconfigfile

Specifies the TSM configuration file.

@tsmdevicetimeoutminutes

Specifies how long to wait for a TSM device.

@tsmobject

Defines the TSM filespace, high level and low level. This argument accepts the following format:

tsm_filespace\tsm_high_level\tsm_low_level

where:

  • tsm_filespace is the logical space on the TSM server that contains a group of files. It can be the drive label name or UNC name.

  • tsm_high_level specifies the directory path in which the file belongs.

  • tsm_low_level specifies actual name of the file.

NOTE: You may only store one item the location specified by this argument. It is not possible to append an object to this location. You can use the -I command-line argument or @init to back up to a non-unique location.

@tsmpassword

The TSM username password. Passwords are case-sensitive.

@tsmpointintime

Specifies the date for restore/to filter results. If it is not passed, LiteSpeed will choose the most recent archived backup. The format is yyyy-mm-dd hh:mm:ss.

NOTE: If the backup was a striped backup and the point-in-times of the various striped files are different (rare but can be different a second or so), then the most recent of the times must be chosen.

@tsmusername

The TSM username ID.

@vlf

Virtual log files are the unit of truncation for the transaction log.

@vlfmaxsize

The maximum size of virtual log files. The number of virtual log files can grow based on the auto growth settings for the log file and how often the active transactions are written to disk. Too many virtual log files can cause transaction log backups to slow down and can also slow down database recovery.

Examples

Encrypted backup conversion

exec master..xp_extractor
@FileName = N'C:\Backups\backup.bkp',
@FileNumber = 1,
@EncryptionKey = N'password',
@Init = 1,
@MTFFile = N'C:\Backups\backup.bkp.bak'

Striped backups

exec master..xp_extractor
@FileName = N'C:\Backups\backupStripe1.bkp',
@FileName = N'C:\Backups\backupStripe2.bkp',
@FileName = N'C:\Backups\backupStripe3.bkp',
@Init = 1,
@MTFFile = N'C:\Backups\backup.1.bak',
@MTFFile = N'C:\Backups\backup.2.bak'

Returns

0 (success) or non-zero (failure). Return codes represent the native error number returned from SQL Server for any errors encountered during the operation.

To capture the output message, run the following:

declare @rmsg varchar(999)
exec master..<xp_extractor> <arguments>, @resultmsg=@rmsg output
select @rmsg

To capture the output message and the result code, run the following:

declare @rc int
declare @rmsg varchar(999)
exec master..<xp_extractor> <arguments>, @resultmsg=@rmsg output, @resultcode=@rc output
select @rc, @rmsg

 

Related Topic

xp_memory_size

-------------------------------------------------

NOTE: Extended stored procedure xp_memory_size has been marked as deprecated. It will be removed from the product in version 9.0.

-------------------------------------------------

Extended stored procedure to return the contiguous memory availability of the system within the SQL Server process space. This is the space to be utilized for the transfer buffer for backup and restore operations.

Syntax

EXEC master.dbo.xp_memory_size

Results

Column Name

Data Type

Description

ContiguousSize

Int

Available contiguous memory in the SQL Server process space in bytes.

 

Related Topic

xp_objectrecovery

Restores a table from backup files. There are several ways to restore a table:

  • Restore table to a database - Allows you to directly restore the table. If a table with the same name already exists in the destination database, LiteSpeed will not overwrite it. However, you can use @destinationtable to rename the new table and restore it to the database.

  • Restore table to a ship directory - Allows you to restore the table later or on a different location.

  • Restore table to a .csv file - Allows you to open the file with Excel or any other spreadsheet application recognizing .csv file format.

NOTES:

  • You can restore objects directly from the Cloud. It is recommended to use this in cases where there is a fast connection between OLR and the Cloud.
  • You cannot restore objects directly from TSM files or tape backups. For more information, see Object Level Restores from TSM Backups.
  • Object Level Recovery does not support SQL Server Transparent Data Encryption (TDE).
  • LiteSpeed may take a long time to read the backup file for large databases, often with little response in the LiteSpeed UI Console. To prevent this, the Optimize Object Level Recovery speed option on the Backup wizard Options page is selected by default to create the index during the backup.
  • Objects are recovered as they existed at the time they were backed up. You cannot recover data to a random point in time.
  • Direct mode - In scenarios where you want the application to work with SQL Server directly using a TCP/IP connection without involving the SQL Server client, you can enable direct mode which significantly improves deployment and configuration of your applications. You can enable and disable the use of direct mode from the the Recover Table Wizard.
  • Tail log processing - In scenarios when you do not require any transaction log backups and the tail log, you can select to bypass tail log processing. Object Level Recovery operations may work much faster in this case. You can enable and disable bypass tail log processing from the toolbar, and when running the Object Level Recovery Wizard and the Recover Table Wizard.

This topic covers:

Syntax

Preview table data

EXEC master.dbo.xp_objectrecovery
@filename = 'backup_file_name' [,...n]
[, @filenumber = n]
[, @encryptionkey = 'encryption_key']
[( , @logfilename = 'log_file_name'
[, @stripedlogfilename = 'striped_log_file_name'] [,...n]
[, @logencryptionkey= 'log_encryption_key']
[, @logfilenumber = n ] ) [,...n]]
[, @difffilename = 'diff_file_name'] [,...n]
[, @difffilenumber = n]
[, @diffencryptionkey = 'diff_encrypt_key']
[, @LSM = 'option' ]
, @objectname = 'object_name'
[, @destinationserver = 'dest_server_name']
[, @tempdirectory = 'recovery_temp_dir']
[, @disablelogprocessing = 0 | 1 ]

Restore table to a database

EXEC master.dbo.xp_objectrecovery
@filename = 'backup_file_name' [,...n]
[, @filenumber = n]
[, @encryptionkey = 'encryption_key']
[( , @logfilename = 'log_file_name'
[, @stripedlogfilename = 'striped_log_file_name'] [,...n]
[, @logencryptionkey= 'log_encryption_key']
[, @logfilenumber = n ] ) [,...n]]
[, @difffilename = 'diff_file_name'] [,...n]
[, @difffilenumber = n]
[, @diffencryptionkey = 'diff_encrypt_key']
[, @LSM = 'option' ]
, @objectname = 'object_name'
, @destinationdatabase = 'database_name'
[, @destinationtable = 'dest_table_name']
[, @prefixtableobjects = N'prefix']
[, @suffixtableobjects = N'suffix']
[, @destinationserver = 'dest_server_name']
[, @tempdirectory = 'recovery_temp_dir']
[, @onfilegroup = 'table_filegroup_name']
[, @textimageonfilegroup = 'blob_filegroup_name']
[, @disablelogprocessing = 0 | 1 ]
[, @includetableobjects = 'options']
[, @OLRUDT = <0|1>]

Restore table to a ship directory

EXEC master.dbo.xp_objectrecovery
@filename = 'backup_file_name' [,...n]
[, @filenumber = n]
[, @encryptionkey = 'encryption_key']
[( , @logfilename = 'log_file_name'
[, @stripedlogfilename = 'striped_log_file_name'] [,...n]
[, @logencryptionkey = 'log_encryption_key']
[, @logfilenumber = n ] ) [,...n]]
[, @difffilename = 'diff_file_name'] [,...n]
[, @difffilenumber = n]
[, @diffencryptionkey = 'diff_encrypt_key']
[, @LSM = 'option' ]
, @objectname = 'object_name'
, @shipdirectory = 'recovery_ship_dir'
[, @destinationtable = 'dest_table_name']
[, @prefixtableobjects = N'prefix']
[, @suffixtableobjects = N'suffix']
[, @onfilegroup = 'table_filegroup_name']
[, @textimageonfilegroup = 'blob_filegroup_name']
[, @disablelogprocessing = 0 | 1 ]
[, @includetableobjects = 'options']
[, @OLRUDT = <0|1>]

Restore table to a .csv file

EXEC master.dbo.xp_objectrecovery
@filename = 'backup_file_name' [,...n]
[, @filenumber = n]
[, @encryptionkey = 'encryption_key']
[( , @logfilename = 'log_file_name'
[, @stripedlogfilename = 'striped_log_file_name'] [,...n]
[, @logencryptionkey = 'log_encryption_key']
[, @logfilenumber = n ] ) [,...n]]
[, @difffilename = 'diff_file_name'] [,...n]
[, @difffilenumber = n]
[, @diffencryptionkey = 'diff_encrypt_key']
[, @LSM = 'option' ]
, @objectname = 'object_name'
, @destinationfilename = 'csv_file_name'
[, @disablelogprocessing = 0 | 1 ]
[, @includetableobjects = 'options']

If the backup is stored in the cloud (Amazon S3) these parameters help us with access

[, @CloudBucketName = N'aabucket1']
[, @CloudAccessKey = N'***']
[, @CloudSecretKey = N'***']
[, @CloudRegionName = N'us-west-2']
[, @ProxyHost = N'proxy.sitelocal']
[, @ProxyPort = 8080]
[, @ProxyLogin = N'DOMAIN\***']
[, @ProxyPassword = N'***']

If the backup is stored in the cloud (Microsoft Azure) these parameters help us with access

@CloudVendor = N'AzureBlob',
@CloudBucketName = N'test',
@CloudAccessKeyEnc = N'*******',
@CloudSecretKeyEnc = N'******',
@UseSSL = 1,
@affinity = 0,
@logging = 0

 

Arguments

Tips:

  • To see the list of accepted arguments and data types for arguments, execute the following:
    exec master.dbo.<procedure_name> show_help

  • To convert the script for use with the command-line utilities, execute the following:
    exec master.dbo.<procedure_name> show_cmd, <xp_arguments>

@AsOnDisk

Instructs LiteSpeed to restore an in-memory table as a regular table. This argument accepts one of the following values:

  • 0—False (Default)
  • 1—True

@backend

Object Level Recovery can restore tables using two different internal techniques to handle the record inserts.

The first and default method uses BCP files and a TSQL BULK INSERT statement. Object Level Recovery will write a BCP format file and an accompanying binary data file to the local file system. These files may become very large depending on the table size and will require permissions to write to a temporary directory. The default TEMP location can be set by using the @TempDirectory parameter or by setting a permanent temp location in the LiteSpeed configuration file.

An alternate insertion method can be specified to use Sql Server’s Sql Native Client capabilities. This method inserts row-data directly into the destination database bypassing any storage on the local file-system. To enable this method, use the parameter @backend='SQLNativeClient' (or -b 1 from the command line). To make this the default method set the value “BackEnd=SQLNativeClient” in the Object Level Recovery section of the LiteSpeed configuration file.

Regardless of the insertion method used, the batch size can be globally managed by setting the value “BulkImportBatchSize=<N>”. This will set the number of row inserts for each batched transaction.

@CloudAccessKey

The @CloudAccessKey argument specifies the name of the unique Cloud Web Service alphanumeric access key that identifies each user. The selections include Amazon Access Key, Azure Account Name, Google e-mail styled account.

@CloudAccessKeyEnc

The @CloudAccessKeyEnc argument specifies the name of the encrypted unique Cloud Web Service alphanumeric access key that identifies each user.

@CloudBucketName

The @CloudBucketName argument specifies the name of the container for cloud objects. Bucket names must be at least 3 and no more than 63 characters long. The selections are Amazon Bucket Name, Azure Container Name, Google Bucket Name. Google Bucket Name requirements are described at https://cloud.google.com/storage/docs/naming.

@CloudGovRegion

The @CloudGovRegion argument enables a special restricted region for the US Government use in Amazon S3 and Azure Clouds. This argument accepts one of the following values:

  • 0—Do not use government cloud (default)
  • 1—Use government cloud

@CloudRegionName

The @CloudRegionName argument specifies the name of the Cloud Web Service region to use for a bucket. Example values are but not limited to: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-central-1, eu-west-1, eu-west-2, ap-south-1, ap-southeast-1, ap-southeast-2, ap-northeast-1, ap-northeast-2, sa-east-1, N'Germany' and N'China'.

@CloudSecretKey

The @CloudSecretKey argument specifies the name of the Cloud Web Service secret key that is assigned when you initially get a Cloud account.

@CloudSecretKeyEnc

The @CloudSecretKeyEnc argument specifies the name of the encrypted Cloud Web Service secret key that is assigned when you initially get a Cloud account.

@CloudVendor

The @CloudVendor argument specifies the name of the cloud service provider. The argument accepts one of the following values: "AmazonS3", "AzureBlob" or "GoogleStorage".

@destinationdatabase

Specifies the destination database.

@destinationfilename

Name of comma separated file (.csv) that is generated instead restoring into a database. This is an ad hoc solution for users want to see the restored data in Excel. You can only use this argument for text data.

@destinationserver

Name of the destination server.

@destinationtable

Specifies the name of the destination table. LiteSpeed will not overwrite an existing table. If you select the same server instance and database as the original table, you must use a different table name.

NOTE: For Execute-Select operations, LiteSpeed will attempt to insert (append) all selected records into existing table.

@diffencryptionkey

Value used to generate the encryption key for the encryption algorithm. If you do not supply encryption key, then the program will not encrypt the backup. If you use the wrong encryption key, the restore will fail.

Caution: When encrypting data, take care not to lose the encryption key; a backup cannot be restored or recovered without the original encryption key.

Example of key: 'Mypassword'

Equivalent to @encryptionkey, but used for differential backups instead of full backup files.

@difffilename

Name of backup file to restore. Used for differential backups instead of full backup files. You can supply multiple instances of this argument.

@difffilenumber

Identifies the backup file within the backup set. Equivalent to @filenumber, but used for differential backups instead of full backup files.

@disablelogprocessing

Instructs LiteSpeed to skip all transaction log backups and tail log processing. This may improve read and recovery times. This argument accepts one of the following values:

  • 0—False (Default).
  • 1—True. LiteSpeed will entirely ignore any transaction log backups specified and will not process the tail log.

@encryptionkey

Value used to generate the encryption key for the encryption algorithm. If you do not supply encryption key, then the program will not encrypt the backup. If you use the wrong encryption key, the restore will fail.

Caution: When encrypting data, take care not to lose the encryption key; a backup cannot be restored or recovered without the original encryption key.

Example of key: 'Mypassword'

@filename

Specifies a backup location (e.g. C:\backups\AdventureWorks.bak). This argument accepts network destinations. You can supply multiple instances of this argument to use stripe backups.

@filenumber

Specifies the particular backup to use when recasting, restoring, extracting or reading from files with multiple appended backups. You can run xp_restore_headeronly to query the files contained within the backup set given by backup_file_name.

@FilestreamOnFileGroup

Specifies a file stream filegroup to include in the object restore.

@includetableobjects

Instructs LiteSpeed to script or recover one or more of the following:

  • Constraints—But not foreign keys
  • ForeignKeys
  • Indexes
  • Statistics
  • Triggers
  • All—All of the above

The value is a list of options, separated with commas.

@logencryptionkey

Value used to generate the encryption key for the encryption algorithm. If you do not supply encryption key, then the program will not encrypt the backup. If you use the wrong encryption key, the restore will fail.

Caution: When encrypting data, take care not to lose the encryption key; a backup cannot be restored or recovered without the original encryption key.

Example of key: 'Mypassword'

Equivalent to @encryptionkey, but used for transaction log backups.

@logfilename

Specifies location and name of the log backup file. You can supply multiple instances of this argument.

Syntax

@logfilenumber

Identifies the log backup file within the backup set. Equivalent to @filenumber, but used for log backups.

@LSM

Specifies handling for OLR LSM mapfile(s).

  • Create—Reads backup and creates a new mapfile. It will ignore attached LSM.
  • Keep—Does not delete mapfile(s) when complete.
  • Delete—Always deletes mapfile(s) when complete.

@objectname

Specifies the name of the object to recover.

@OLRUDT

Create table script:

  • 0—Off. Create table with native types, if possible; othervise (CLR UDT) create with UDT. (Default).
  • 1—On. Create table with UDT.

@onfilegroup

Filegroup with the object to restore.

@PersistLogProcessing

Instructs LiteSpeed to persist log processing, so the same database backup does not have to be processed for each Object Level Recovery operation. This argument accepts one of the following values:

  • 0—False (Default).
  • 1—True. LiteSpeed will persist transaction log backups specified and the tail log for future use. This option can offer a huge performance gain for working with databases with large tail logs that could possibly take a long time to process.

@prefixtableobjects

Adds a prefix to the names of the table's objects you selected to script or recover.

@ProxyHost

The @ProxyHost argument is optional and specifies the name of the proxy host name that is running the proxy server.

note: If the @ProxyHost argument is not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@ProxyLogin

The @ProxyLogin argument is optional and specifies the proxy server login credential.

note: If not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@ProxyPassword

The @ProxyPassword argument is optional and specifies the proxy server password credential.

note: If the @ProxyPassword argument is not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@ProxyPasswordEnc

The @ProxyPasswordEnc argument is optional and specifies the encrypted proxy server password credential.

note: If the @ProxyPasswordEnc argument is not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@ProxyPort

The @ProxyPort argument is optional and contains the port number of the proxy server. The TCP/IP port values can be 1-65535.

note: If the @ProxyPort argument is not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@shipdirectory

Name of the ship directory. Use this argument when you want to restore the object later or at a different physical location.  This argument creates the following files in the ship directory:

  • CREATE <object_name>.sql

  • BULK INSERT <object_name>.sql

  • <object_name>.fmt

  • <object_name>.bcp

To restore the object, run the CREATE file first, and then run the BULK INSERT file. You will need to slightly modify the BULK INSERT file because of the .fmt and .bcp file path names.

Tip: You can zip the files and send them to someone else.

@Status_FileName

Specifies the status of a backup location.

@stripedlogfilename

Specifies the striped log file name.

NOTE: The striped files for a given log backup must be specified before the next log backup set is specified.

@suffixtableobjects

Adds a suffix to the names of the table's objects you selected to script or recover.

@tempdirectory

Specifies a temporary directory for use with Object Level Recovery. Use this argument when the default Windows temp directory does not have enough free disk space for the restore process.

NOTE: You can specify the default temp directory using the TempPath parameter in the [LiteSpeed] section of the LiteSpeedSettings.ini file. (Usually, C:\Documents and Settings\All Users\Application Data\Quest Software\LiteSpeed\SQL Server\LiteSpeedSettings.ini.)

@textimageonfilegroup

Destination TEXTIMAGE_ON filegroup name. Used to restore a BLOB (binary large object).

@UseSSL

The @UseSSL argument specifies that the connection uses SSL security. This argument accepts one of the following values:

  • 0—Do not use SSL
  • 1—Use SSL (default)

@with

Each @with argument should be a syntactically complete and correct statement. Please refer to the SQL Server Transact-SQL backup and restore documentation for the syntax and usage.

The supported formats are:

  • @with='PARAMETER'
  • @with='PARAMETER=''accepted_value'''

NOTES:

  • Extended stored procedure arguments are limited to 255 characters. If you need more than 255 characters, use multiple @with arguments.
  • Do not supply the @with parameter if no additional features are required.

This extended stored procedure accepts the following @with parameters:

Parameter

Description

KEEP_REPLICATION

Instructs the restore operation to keep the replication settings when restoring a published database to a server other than that on which it was created (used when setting up replication with log shipping). You cannot specify this parameter with NORECOVERY.

MOVE

MOVE = ''logical_file_name'' TO ''operating_system_file_name''

Specifies that the given logical_file_name should be moved to operating_system_file_name. By default, the logical_file_name is restored to its original location.

If you use xp_restore_database to copy a database to the same or different server, the MOVE parameter may be needed to relocate the database files and to avoid collisions with existing files. Each logical file in the database can be specified in different MOVE statements.

Example:

EXEC master.dbo.xp_restore_database @database = 'MyDB'

, @filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'

, @with = 'MOVE ''MyDB_Data'' TO ''C:\MSSQL\Data\MyDB_data.MDF'''

, @with = 'MOVE ''MyDB_Data2'' TO ''C:\MSSQL\Data\MyDB_data2.NDF'''

, @with = 'MOVE ''MyDB_Log'' TO ''C:\MSSQL\Data\MyDB_log.LDF'''

NOTE: Use xp_restore_filelistonly to obtain a list of the logical files from the backup set. xp_restore_filelistonly

NORECOVERY

Instructs the restore operation to not roll back any uncommitted transactions. Either the NORECOVERY or STANDBY option must be specified if another transaction log has to be applied. If NORECOVERY, RECOVERY, or STANDBY is not specified, RECOVERY is the default.

SQL Server requires that the WITH NORECOVERY option is used on all but the final xp_restore_log statement when restoring a database backup and multiple transaction logs using LiteSpeed, or when multiple xp_restore_database or xp_restore_log statements are needed (for example, a full database backup followed by a differential database backup).

NOTE: When specifying the NORECOVERY option, the database is not usable in this intermediate, non-recovered state.

When used with a file or filegroup restore operation, NORECOVERY forces the database to remain in the restoring state after the restore operation. This is useful in either of these situations:

  • a restore script is being run and the log is always being applied.

  • a sequence of file restores is used and the database is not intended to be usable between two of the restore operations.

PARTIAL

Specifies a partial restore operation.

The granularity of the partial restore operation is the database filegroup. The primary file and filegroup are always restored, along with the files that you specify and their corresponding filegroups. The result is a subset of the database. Filegroups that are not restored are marked as offline and are not accessible.

RECOVERY

Instructs the restore operation to roll back any uncommitted transactions. After the recovery process, the database is ready for use.

If subsequent LiteSpeed restore operations (xp_restore_log or xp_restore_database from differential) are planned, NORECOVERY or STANDBY should be specified instead.

If NORECOVERY, RECOVERY, or STANDBY is not specified, RECOVERY is the default.

When restoring backup sets from an earlier version of SQL Server, a database upgrade may be required. This upgrade is performed automatically when WITH RECOVERY is specified.

REPLACE

Instructs LiteSpeed to create the specified database and its related files even if another database already exists with the same name. The existing database is deleted.

When the this option is not specified, LiteSpeed performs a check to ensure that the database is not restored to the current server if:

  • the database named in the xp_restore_database statement already exists on the current server, and

  • the database name is different from the database name recorded in the LiteSpeed backup set.

LiteSpeed will overwrite an existing file which cannot be verified as belonging to the database being restored. Normally, LiteSpeed will refuse to overwrite pre-existing files.

RESTRICTED_USER

When used in conjunction with recovery (another with param and the default) leaving a usable database, this restricts access for the restored database to members of the db_owner, dbcreator, or sysadmin roles.

STANDBY

STANDBY = ''undo_file_name''

Specifies the undo file name so the recovery effects can be undone. The size required for the undo file depends on the volume of undo actions resulting from uncommitted transactions. If you do not specify NORECOVERY, RECOVERY, or STANDBY, LiteSpeed defaults to RECOVERY.

STANDBY allows a database to be brought up for read-only access between transaction log restores and can be used with either warm standby server situations or special recovery situations in which it is useful to inspect the database between log restores.

If the specified undo file name does not exist, LiteSpeed creates it. If the file does exist, LiteSpeed overwrites it.

The same undo file can be used for consecutive LiteSpeed restores of the same database.

NOTE: If free disk space is exhausted on the drive containing the specified undo file name, the LiteSpeed restore operation stops.

STATS

Displays a message each time a percentage of the activity completes. The default is 10%.
CHECKSUM

Causes checksums to be verified when a LiteSpeed backup is created.

NOTE: When you restore a backup containing checksum, it is automatically checked. If you do not want to check the checksums during a restore, supply 'NO_CHECKSUM' .

PASSWORD Specifies the password for the backup set.

Examples

Preview a table from a full backup file

EXEC master.dbo.xp_objectrecovery
@filename='C:\MSSQL\Backup\MyDB_Backup.BAK',
@filenumber = 1,
@objectname='dbo.Customers'

Restore a table from a full backup file into a database

EXEC master.dbo.xp_objectrecovery
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @filenumber = 1,
, @objectname = 'dbo.Customers'
, @destinationdatabase = 'tempdb'

Restore multiple tables and tables' constraints and indexes

exec xp_objectrecovery
@FileName = N'C:\temp\HiServ_full.bak',
@FileNumber = 1,
@ObjectName = N'dbo.Roles',
@DestinationTable = N'[dbo].[Roles]',
@DestinationDatabase = N'HiServ',
@DestinationServer = N'w2k3-22\LITESPEED',
@IncludeTableObjects = N'indexes, constraints, foreignKeys'

exec xp_objectrecovery
@FileName = N'C:\temp\HiServ_full.bak',
@FileNumber = 1,
@ObjectName = N'dbo.Employees',
@DestinationTable = N'[dbo].[Employees]',
@DestinationDatabase = N'HiServ',
@DestinationServer = N'w2k3-22\LITESPEED',
@IncludeTableObjects = N'indexes, constraints, foreignKeys'

exec xp_objectrecovery
@FileName = N'C:\temp\HiServ_full.bak',
@FileNumber = 1,
@ObjectName = N'dbo.Customers',
@DestinationTable = N'[dbo].[Customers]',
@DestinationDatabase = N'HiServ',
@DestinationServer = N'w2k3-22\LITESPEED',
@IncludeTableObjects = N'indexes, constraints, foreignKeys'

exec xp_objectrecovery
@FileName = N'C:\temp\HiServ_full.bak',
@FileNumber = 1,
@ObjectName = N'dbo.Projects',
@DestinationTable = N'[dbo].[Projects]',
@DestinationDatabase = N'HiServ',
@DestinationServer = N'w2k3-22\LITESPEED',
@IncludeTableObjects = N'indexes, constraints, foreignKeys'

exec xp_objectrecovery
@FileName = N'C:\temp\HiServ_full.bak',
@FileNumber = 1,
@ObjectName = N'dbo.Positions',
@DestinationTable = N'[dbo].[Positions]',
@DestinationDatabase = N'HiServ',
@DestinationServer = N'w2k3-22\LITESPEED',
@IncludeTableObjects = N'indexes, constraints, foreignKeys'

Restore a table from a full backup file to a database using table, server, filegroup and temp directory parameters

EXEC master.dbo.xp_objectrecovery
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @objectname = 'dbo.Customers'
, @destinationdatabase = 'tempdb'
, @destinationtable = 'dbo.Restored_Customers'
, @destinationserver = 'MyMachine\SQL2000'
, @tempdirectory = 'D:\temp'
, @onfilegroup = 'Secondary'
, @textimageonfilegroup = 'Secondary'

Restore a table from a striped backup

EXEC master.dbo.xp_objectrecovery
@filename='C:\TestSCriptBackups\full_Mon'
, @filename='C:\TestSCriptBackups\'
, @filenumber=1
, @encryptionkey = 'key'
, @logfilename='C:\TestSCriptBackups\Log_Mon_0900_1'
, @logencryptionkey = 'key'
, @stripedlogfilename='C:\TestSCriptBackups\Log_Mon_0900_2'
, @stripedlogfilename='C:\TestSCriptBackups\Log_Mon_0900_3'
, @logfilenumber=1
, @destinationtable='dbo.employees_recovered'
, @destinationdatabase='OLRRegressionTest'
, @objectname='dbo.employees'

Restore a table from a full backup file to a ship directory

EXEC master.dbo.xp_objectrecovery
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @objectname = 'dbo.Customers'
, @shipdirectory = 'C:\temp\ship'

Restore a table from a full backup file to a .csv file

EXEC master.dbo.xp_objectrecovery
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @objectname = 'dbo.Customers'
, @destinationfilename = 'C:\temp\Customers.csv'

Returns

0 (success) or non-zero (failure). Return codes represent the native error number returned from SQL Server for any errors encountered during the operation.

To capture the output message, run the following:

declare @rmsg varchar(999)
exec master..<procedure_name> <arguments>, @resultmsg=@rmsg output
select @rmsg

To capture the output message and the result code, run the following:

declare @rc int
declare @rmsg varchar(999)
exec master..<procedure_name> <arguments>, @resultmsg=@rmsg output, @resultcode=@rc output
select @rc, @rmsg

 

Related Topics

xp_objectrecovery_createscript

Creates DDL scripts. You can use this extended stored procedure to restore objects other than tables by generating the DDL scripts and then running the scripts in your native SQL Server tool (such as Management Studio).

NOTE:

When using scripts, the message output results are rendered in a multi row, single column result set so other products can programmatically acquire the script without having to parse the message results. The script then remains in the message output and result set locations.Object Level Restores from TSM Backups

This topic covers:

Syntax

EXEC master.dbo.xp_objectrecovery_createscript
(@filename = 'backup_file_name') [,...n]
[, @filenumber = n]
[, @encryptionkey = 'encryption_key']
[( , @logfilename = 'log_file_name'
[, @stripedlogfilename = 'striped_log_file_name'] [,...n]
[, @logencryptionkey = 'log_encryption_key']
[, @logfilenumber = n ] ) [,...n]]
[, @difffilename = 'diff_file_name'] [,...n]
[, @difffilenumber = n]
[, @diffencryptionkey = 'diff_encrypt_key']
[, @LSM = 'option' ]
, @objectname = 'object_name'
, @objectfilename = 'object_file_name'
, @scriptfilename = 'script_file_name'
[, @type = 'object_type']
[, @onfilegroup = 'table_filegroup_name']
[, @textimageonfilegroup = 'blob_filegroup_name']
[, @disablelogprocessing = 0 | 1 ]
[, @includetableobjects = 'options']
[, @prefixtableobjects = N'prefix']
[, @suffixtableobjects = N'suffix']
[, @OLRUDT = <0|1>]

Create the DDL script (Amazon S3)

EXEC master.dbo.xp_objectrecovery_createscript
@filename = 'backup_file_name'
, @CloudVendor = N'AmazonS3'
, @Database = N'AA_5_restored88'
[, @CloudBucketName = N'aabucket1']
[, @CloudAccessKey = N'***']
[, @CloudSecretKey = N'***']
[, @CloudRegionName = N'us-west-2']
[, @ProxyHost = N'proxy.sitelocal']
[, @ProxyPort = 8080]
[, @ProxyLogin = N'DOMAIN\temp-xyz-MYtester']
[, @ProxyPassword = N'***']
[, @OLRUDT = <0|1>]

Create the DDL script (Microsoft Azure)

EXEC master.dbo.xp_objectrecovery_createscript
@filename = 'backup_file_name'
@database = N'model' ,
@CloudVendor = N'AzureBlob',
@CloudBucketName = N'test',
@CloudAccessKeyEnc = N'*******',
@CloudSecretKeyEnc = N'******',
@UseSSL = 1,
@affinity = 0,
@logging = 0,
@OLRUDT = 0

Arguments

Tips:

  • To see the list of accepted arguments and data types for arguments, execute the following:
    exec master.dbo.<procedure_name> show_help

  • To convert the script for use with the command-line utilities, execute the following:
    exec master.dbo.<procedure_name> show_cmd, <xp_arguments>

@AsOnDisk

Instructs LiteSpeed to restore an in-memory table as a regular table. This argument accepts one of the following values:

  • 0—False (Default)
  • 1—True

@CloudAccessKey

The @CloudAccessKey argument specifies the name of the unique Cloud Web Service alphanumeric access key that identifies each user. The selections include Amazon Access Key, Azure Account Name, Google e-mail styled account.

@CloudAccessKeyEnc

The @CloudAccessKeyEnc argument specifies the name of the encrypted unique Cloud Web Service alphanumeric access key that identifies each user.

@CloudBucketName

The @CloudBucketName argument specifies the name of the container for cloud objects. Bucket names must be at least 3 and no more than 63 characters long. The selections are Amazon Bucket Name, Azure Container Name, Google Bucket Name. Google Bucket Name requirements are described at https://cloud.google.com/storage/docs/naming.

@CloudGovRegion

The @CloudGovRegion argument enables a special restricted region for the US Government use in Amazon S3 and Azure Clouds. This argument accepts one of the following values:

  • 0—Do not use government cloud (default)
  • 1—Use government cloud

@CloudRegionName

The @CloudRegionName argument specifies the name of the Cloud Web Service region to use for a bucket. Example values are but not limited to: us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, eu-central-1, eu-west-1, eu-west-2, ap-south-1, ap-southeast-1, ap-southeast-2, ap-northeast-1, ap-northeast-2, sa-east-1, N'Germany' and N'China'.

@CloudSecretKey

The @CloudSecretKey argument specifies the name of the Cloud Web Service secret key that is assigned when you initially get a Cloud account.

@CloudSecretKeyEnc

The @CloudSecretKeyEnc argument specifies the name of the encrypted Cloud Web Service secret key that is assigned when you initially get a Cloud account.

@CloudVendor

The @CloudVendor argument specifies the name of the cloud service provider. The argument accepts one of the following values: "AmazonS3", "AzureBlob" or "GoogleStorage".

@diffencryptionkey

Value used to generate the encryption key for the encryption algorithm. If you do not supply encryption key, then the program will not encrypt the backup. If you use the wrong encryption key, the restore will fail.

Caution: When encrypting data, take care not to lose the encryption key; a backup cannot be restored or recovered without the original encryption key.

Example of key: 'Mypassword'

Equivalent to @encryptionkey, but used for differential backups instead of full backup files.

@difffilename

Name of backup file to restore. Used for differential backups instead of full backup files. You can supply multiple instances of this argument.

@difffilenumber

Identifies the backup file within the backup set. Equivalent to @filenumber, but used for differential backups instead of full backup files.

@disablelogprocessing

Instructs LiteSpeed to skip all transaction log backups and tail log processing. This may improve read and recovery times. This argument accepts one of the following values:

  • 0—False (Default).
  • 1—True. LiteSpeed will entirely ignore any transaction log backups specified and will not process the tail log.

@encryptionkey

Value used to generate the encryption key for the encryption algorithm. If you do not supply encryption key, then the program will not encrypt the backup. If you use the wrong encryption key, the restore will fail.

Caution: When encrypting data, take care not to lose the encryption key; a backup cannot be restored or recovered without the original encryption key.

Example of key: 'Mypassword'

@filename

Specifies a backup location (e.g. C:\backups\AdventureWorks.bak). This argument accepts network destinations. You can supply multiple instances of this argument to use stripe backups.

@filenumber

Specifies the particular backup to use when recasting, restoring, extracting or reading from files with multiple appended backups. You can run xp_restore_headeronly to query the files contained within the backup set given by backup_file_name.

@FilestreamOnFileGroup

Specifies a file stream filegroup to include in the object restore.

@includetableobjects

Instructs LiteSpeed to script or recover one or more of the following:

  • Constraints—But not foreign keys
  • ForeignKeys
  • Indexes
  • Statistics
  • Triggers
  • All—All of the above

The value is a list of options, separated with commas.

@logencryptionkey

Value used to generate the encryption key for the encryption algorithm. If you do not supply encryption key, then the program will not encrypt the backup. If you use the wrong encryption key, the restore will fail.

Caution: When encrypting data, take care not to lose the encryption key; a backup cannot be restored or recovered without the original encryption key.

Example of key: 'Mypassword'

Equivalent to @encryptionkey, but used for transaction log backups.

@logfilename

Specifies location and name of the log backup file. You can supply multiple instances of this argument.

Syntax

@logfilenumber

Identifies the log backup file within the backup set. Equivalent to @filenumber, but used for log backups.

@LSM

Specifies handling for OLR LSM mapfile(s).

  • Create—Reads backup and creates a new mapfile. It will ignore attached LSM.
  • Keep—Does not delete mapfile(s) when complete.
  • Delete—Always deletes mapfile(s) when complete.

@objectfilename

Identifies a file that contains a list of objects. The format of this file is "ObjectType,ObjectName" per line.

You can create the list using xp_objectrecovery_viewcontents. xp_objectrecovery_viewcontents

@objectname

Specifies the name of the object to recover.

@OLRUDT

Create table script:

  • 0—Off. Create table with native types, if possible; othervise (CLR UDT) create with UDT. (Default).
  • 1—On. Create table with UDT.

@onfilegroup

Filegroup with the object to restore.

@PersistLogProcessing

Instructs LiteSpeed to persist log processing, so the same database backup does not have to be processed for each Object Level Recovery operation. This argument accepts one of the following values:

  • 0—False (Default).
  • 1—True. LiteSpeed will persist transaction log backups specified and the tail log for future use. This option can offer a huge performance gain for working with databases with large tail logs that could possibly take a long time to process.

@prefixtableobjects

Adds a prefix to the names of the table's objects you selected to script or recover.

@ProxyHost

The @ProxyHost argument is optional and specifies the name of the proxy host name that is running the proxy server.

note: If the @ProxyHost argument is not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@ProxyLogin

The @ProxyLogin argument is optional and specifies the proxy server login credential.

note: If not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@ProxyPassword

The @ProxyPassword argument is optional and specifies the proxy server password credential.

note: If the @ProxyPassword argument is not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@ProxyPasswordEnc

The @ProxyPasswordEnc argument is optional and specifies the encrypted proxy server password credential.

note: If the @ProxyPasswordEnc argument is not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@ProxyPort

The @ProxyPort argument is optional and contains the port number of the proxy server. The TCP/IP port values can be 1-65535.

note: If the @ProxyPort argument is not defined, then the LiteSpeed core engine checks the local .ini files for the proxy parameters. If the proxy parameters are not detected, then the LiteSpeed core engine connects directly to the proxy servers.

@scriptfilename

Name of the script file to save the generated SQL scripts.

@Status_FileName

Specifies the status of a backup location.

@stripedlogfilename

Specifies the striped log file name.

NOTE: The striped files for a given log backup must be specified before the next log backup set is specified.

@suffixtableobjects

Adds a suffix to the names of the table's objects you selected to script or recover.

@textimageonfilegroup

Destination TEXTIMAGE_ON filegroup name. Used to restore a BLOB (binary large object).

@type

Specifies the type of object. If you omit this parameter the object type defaults to table, so you should use this argument to recover schema objects other than tables. This argument accepts one of the following values:

  • All 1, 3
  • Database
  • Default
  • ExtendedProcedure
  • Function
  • IndexedView
  • MemoryOptimizedTable
  • PartitionFunction
  • PartitionScheme
  • Role 1
  • Rule
  • StoredProcedure
  • SystemTable
  • Table
  • TableConstraintClustered 2
  • TableConstraints 2
  • TableForeignKeys 2
  • TableIndexClustered 2
  • TableIndexes 2
  • TableStatistics2

  • TableTriggers 2
  • Trigger
  • Type
  • User 1
  • View
  • XmlSchemaCollection

Notes:
1 These values cannot be used to create scripts.
2 These values are pseudo-object types and are not real schema objects. They are only used to generate SQL scripts to alter the table, and they will be ignored when used with -V or xp_objectrecovery_viewcontents. When one of these values is used with -C or xp_objectrecovery_createscript, @ObjectName (-C) is not the name of the object, but the name of the owning table.
3 This value lists all object types, which are prefixed with "object_type, ". All pseudo-table object types will be listed even though they might not exist for the associated table.

@UseSSL

The @UseSSL argument specifies that the connection uses SSL security. This argument accepts one of the following values:

  • 0—Do not use SSL
  • 1—Use SSL (default)

@with

Each @with argument should be a syntactically complete and correct statement. Please refer to the SQL Server Transact-SQL backup and restore documentation for the syntax and usage.

The supported formats are:

  • @with='PARAMETER'
  • @with='PARAMETER=''accepted_value'''

NOTES:

  • Extended stored procedure arguments are limited to 255 characters. If you need more than 255 characters, use multiple @with arguments.
  • Do not supply the @with parameter if no additional features are required.

This extended stored procedure accepts the following @with parameters:

Parameter

Description

KEEP_REPLICATION

Instructs the restore operation to keep the replication settings when restoring a published database to a server other than that on which it was created (used when setting up replication with log shipping). You cannot specify this parameter with NORECOVERY.

MOVE

MOVE = ''logical_file_name'' TO ''operating_system_file_name''

Specifies that the given logical_file_name should be moved to operating_system_file_name. By default, the logical_file_name is restored to its original location.

If you use xp_restore_database to copy a database to the same or different server, the MOVE parameter may be needed to relocate the database files and to avoid collisions with existing files. Each logical file in the database can be specified in different MOVE statements.

Example:

EXEC master.dbo.xp_restore_database @database = 'MyDB'

, @filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'

, @with = 'MOVE ''MyDB_Data'' TO ''C:\MSSQL\Data\MyDB_data.MDF'''

, @with = 'MOVE ''MyDB_Data2'' TO ''C:\MSSQL\Data\MyDB_data2.NDF'''

, @with = 'MOVE ''MyDB_Log'' TO ''C:\MSSQL\Data\MyDB_log.LDF'''

NOTE: Use xp_restore_filelistonly to obtain a list of the logical files from the backup set. xp_restore_filelistonly

NORECOVERY

Instructs the restore operation to not roll back any uncommitted transactions. Either the NORECOVERY or STANDBY option must be specified if another transaction log has to be applied. If NORECOVERY, RECOVERY, or STANDBY is not specified, RECOVERY is the default.

SQL Server requires that the WITH NORECOVERY option is used on all but the final xp_restore_log statement when restoring a database backup and multiple transaction logs using LiteSpeed, or when multiple xp_restore_database or xp_restore_log statements are needed (for example, a full database backup followed by a differential database backup).

NOTE: When specifying the NORECOVERY option, the database is not usable in this intermediate, non-recovered state.

When used with a file or filegroup restore operation, NORECOVERY forces the database to remain in the restoring state after the restore operation. This is useful in either of these situations:

  • a restore script is being run and the log is always being applied.

  • a sequence of file restores is used and the database is not intended to be usable between two of the restore operations.

PARTIAL

Specifies a partial restore operation.

The granularity of the partial restore operation is the database filegroup. The primary file and filegroup are always restored, along with the files that you specify and their corresponding filegroups. The result is a subset of the database. Filegroups that are not restored are marked as offline and are not accessible.

RECOVERY

Instructs the restore operation to roll back any uncommitted transactions. After the recovery process, the database is ready for use.

If subsequent LiteSpeed restore operations (xp_restore_log or xp_restore_database from differential) are planned, NORECOVERY or STANDBY should be specified instead.

If NORECOVERY, RECOVERY, or STANDBY is not specified, RECOVERY is the default.

When restoring backup sets from an earlier version of SQL Server, a database upgrade may be required. This upgrade is performed automatically when WITH RECOVERY is specified.

REPLACE

Instructs LiteSpeed to create the specified database and its related files even if another database already exists with the same name. The existing database is deleted.

When the this option is not specified, LiteSpeed performs a check to ensure that the database is not restored to the current server if:

  • the database named in the xp_restore_database statement already exists on the current server, and

  • the database name is different from the database name recorded in the LiteSpeed backup set.

LiteSpeed will overwrite an existing file which cannot be verified as belonging to the database being restored. Normally, LiteSpeed will refuse to overwrite pre-existing files.

RESTRICTED_USER

When used in conjunction with recovery (another with param and the default) leaving a usable database, this restricts access for the restored database to members of the db_owner, dbcreator, or sysadmin roles.

STANDBY

STANDBY = ''undo_file_name''

Specifies the undo file name so the recovery effects can be undone. The size required for the undo file depends on the volume of undo actions resulting from uncommitted transactions. If you do not specify NORECOVERY, RECOVERY, or STANDBY, LiteSpeed defaults to RECOVERY.

STANDBY allows a database to be brought up for read-only access between transaction log restores and can be used with either warm standby server situations or special recovery situations in which it is useful to inspect the database between log restores.

If the specified undo file name does not exist, LiteSpeed creates it. If the file does exist, LiteSpeed overwrites it.

The same undo file can be used for consecutive LiteSpeed restores of the same database.

NOTE: If free disk space is exhausted on the drive containing the specified undo file name, the LiteSpeed restore operation stops.

STATS

Displays a message each time a percentage of the activity completes. The default is 10%.
CHECKSUM

Causes checksums to be verified when a LiteSpeed backup is created.

NOTE: When you restore a backup containing checksum, it is automatically checked. If you do not want to check the checksums during a restore, supply 'NO_CHECKSUM' .

PASSWORD Specifies the password for the backup set.

Examples

Generate SQL script to create a database

EXEC master.dbo.xp_objectrecovery_createscript
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @type = 'Database'
, @scriptfilename = 'C:\sql\CREATE_DATABASE.sql'

Generate SQL scripts to create a table

EXEC master.dbo.xp_objectrecovery_createscript
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @objectname = 'dbo.Customers'
, @scriptfilename = 'C:\sql\CREATE_Customers.sql'

Generate SQL scripts to restore a table, including table's indexes, constraints and foreign keys

EXEC master.dbo.xp_objectrecovery_createscript
@filename='C:\MSSQL\Backup\MyDB_Backup.BAK'
, @type='table'
, @objectname='tbl'
, @prefixtableobjects='test_'
, @includetableobjects='indexes, constraints, foreignkeys'

Generate SQL scripts to alter a table

EXEC master.dbo.xp_objectrecovery_createscript
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @objectname = 'dbo.Customers'
, @scriptfilename = 'C:\sql\ALTER_Customers.sql'
, @type = 'TableConstraintClustered'

Generate SQL scripts to create a view

EXEC master.dbo.xp_objectrecovery_createscript 
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @objectname = 'dbo.Invoices'
, @scriptfilename = 'C:\sql\CREATE_VIEW_Invoices.sql'
, @type = 'View'

Generate SQL scripts for objects listed in an object file

EXEC master.dbo.xp_objectrecovery_createscript
@filename = 'C:\MSSQL\Backup\MyDB_Backup.BAK'
, @objectfilename = 'C:\temp\MyDB_All.txt'
, @scriptfilename = 'C:\sql\CREATE_VIEW_Invoices.sql'

 

Where the MyDB_ALL.txt looks like the following:

Table,dbo.Customers

Table,dbo.[Order Details]

Table,dbo.Orders

Table,dbo.Products

TableConstraintClustered,dbo.Customers

TableConstraintClustered,dbo.[Order Details]

TableConstraintClustered,dbo.Orders

TableConstraintClustered,dbo.Products

TableIndexClustered,dbo.Customers

TableIndexClustered,dbo.[Order Details]

TableIndexClustered,dbo.Orders

TableIndexClustered,dbo.Products

TableConstraints,dbo.Customers

TableConstraints,dbo.[Order Details]

TableConstraints,dbo.Orders

TableConstraints,dbo.Products

TableIndexes,dbo.Customers

TableIndexes,dbo.[Order Details]

TableIndexes,dbo.Orders

TableIndexes,dbo.Products

TableForeignKeys,dbo.Customers

TableForeignKeys,dbo.[Order Details]

TableForeignKeys,dbo.Orders

TableForeignKeys,dbo.Products

TableTriggers,dbo.Customers

TableTriggers,dbo.[Order Details]

TableTriggers,dbo.Orders

TableTriggers,dbo.Products

View,dbo.[Current Product List]

StoredProcedure,dbo.CustOrdersDetail

StoredProcedure,dbo.[Sales by Year]

StoredProcedure,dbo.[Ten Most Expensive Products]

Returns

0 (success) or non-zero (failure). Return codes represent the native error number returned from SQL Server for any errors encountered during the operation.

To capture the output message, run the following:

declare @rmsg varchar(999)
exec master..<procedure_name> <arguments>, @resultmsg=@rmsg output
select @rmsg

To capture the output message and the result code, run the following:

declare @rc int
declare @rmsg varchar(999)
exec master..<procedure_name> <arguments>, @resultmsg=@rmsg output, @resultcode=@rc output
select @rc, @rmsg

 

Related Topics

Documents connexes

The document was helpful.

Sélectionner une évaluation

I easily found the information I needed.

Sélectionner une évaluation