MCITP

MCITP

Friday, March 8, 2013

How to restore database using Litespeed backup file and TSQL command

Below is TSQL script to restore database in MSSQL using Litespeed backup file.

exec master.dbo.xp_restore_database @database = N'databasename' ,

@filename = N'Full path of the backup file',
@filenumber = 1,
@with = N'STATS = 10',
@with = N'MOVE N''LogicalFileNameOf MDF file'' TO N''Destinationpath\Logicalfilename.mdf''',
@with = N'MOVE N''LogicalFileNameOf LDF file'' TO N''Destinationpath\Logicalfilename.ldf''',
@affinity = 0,
@logging = 0
GO

Example :-


exec master.dbo.xp_restore_database @database = N'Test' ,
@filename = N'Q:\Backup\Test_20130308.bak',
@filenumber = 1,
@with = N'STATS = 10',
@with = N'MOVE N''Test'' TO N''M:\data\Test.mdf''',
@with = N'MOVE N''Test_log'' TO N''H:\logs\Test_log.ldf''',
@affinity = 0,
@logging = 0
GO



5 comments:

  1. Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.
    http://www.sqlservermasters.com/

    ReplyDelete

  2. Very Usefull Inforamtion,Thanks for sharing SQL Content Keep Updating US..............

    ReplyDelete

  3. Hi,
    Thanks for sharing the great information... Its useful and helpful information…Keep Sharing.

    SQL DBA training in Hyderabad

    ReplyDelete

Followers