0

I want to restore database in SQL Server 2008 R2 using a bak file and stored procedure of Lite speed. Below is my Code:

USE Master
Go 
exec master.dbo.XP_RESTORE_DATABASE
@database="abc"
,@filename='M:\BACKUPS\xyz.bak'
,@WITH= 'REPLACE'
,@WITH= 'MOVE' "abc_DATA" TO "H:\SQLDATA\ABC.mdf"'
,@WITH= 'MOVE' "abc_LOG" TO "H:\SQLDATA\ABC.ldf"'
GO

After executing the above query I got below error:

Incorrect Syntax near 'abc_DATA'.

I don't know why I am getting this error as I always used this query to restore database.

8
  • That doesn't look right - you have imbalanced ' characters there. A quick hunt suggests that the ' immediately after MOVE shouldn't be there. Commented Oct 10, 2017 at 7:21
  • Why aren't you using the RESTORE command? Commented Oct 10, 2017 at 7:36
  • xp_restore_database is not a SQL Server procedure. It's a part of the Litespeed product Commented Oct 10, 2017 at 7:37
  • Litespeed's docs for xp_restore_database. In any case, your string parameter terminates righ after 'MOVE'. That second ' means only MOVE is part of the string. Remove it in both cases, ie write ,@WITH= 'MOVE "abc_DATA" TO "H:\SQLDATA\ABC.mdf"' Commented Oct 10, 2017 at 7:38
  • @PanagiotisKanavos - the litespeed tag doesn't appear to be anything to do with a database product. Commented Oct 10, 2017 at 7:42

2 Answers 2

1

This should work:

RESTORE DATABASE [abc]
FROM DISK = [DiskLocation]
WITH MOVE 'abc_data' TO ' H:\SQLDATA\ABC.mdf'
,MOVE 'abc_log' TO 'H:\SQLDATA\ABC.ldf'
Sign up to request clarification or add additional context in comments.

2 Comments

It appears that they're using a separate product for managing their backups. Possibly with compression. It's unlikely that the native RESTORE command can comprehend the contents of the backup file.
Thanks for pointing that out Damien, i wasn't initially aware.
0

XP_RESTORE_DATABASE isn't a SQL Server procedure. It's part of Quest's LiteSpeed product . The docs for xp_restore_database are here

Second, the message explains what's wrong. The call isn't correct. The string value passed to the @WITH parameter is terminated right after MOVE and followed by an object identifier "abc_DATA".

The call should be :

exec master.dbo.XP_RESTORE_DATABASE @database="abc", @filename='M:\BACKUPS\xyz.bak'
        ,@WITH= 'REPLACE'
        ,@WITH= 'MOVE "abc_DATA" TO "H:\SQLDATA\ABC.mdf"'
        ,@WITH= 'MOVE "abc_LOG" TO "H:\SQLDATA\ABC.ldf"'

You'll notice that syntax coloring paints the entire string red now.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.