Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Restore problem

Author  Topic 

epb
Starting Member

1 Post

Posted - 2009-11-05 : 09:06:57
Using SQL Server Management Studio 2008: I have two databases on the same remote server and I would like to restore the contents of database A into database B. My user is a member of the db_owner group on both databases, but when I try to restore I get "User does not have permission to restore database B". I have searched the web for a solution without success. Everywhere they mention that the user should be dbo if the database exists, and this is exactly my setup. Any hints?

crosan
Starting Member

13 Posts

Posted - 2009-11-10 : 13:10:24
If you intend to do a full restore of database A as Database B (end result: you have two copies of A, one named A and one named B).

The only permission you should need is owner in database B, however being the owner of the database and being a member of the db_owner role are two different things.

If you run sp_helpdb, this should tell you who the current owner of database B is. If this is not the account you're signed in as, you'll either need to be promoted to owner by someone with more priviliges or have them do the restore for you.

If the system DBA is okay with granting ownership to database B, they'll need to run the following after they have removed your user account from database B.

(be sure to run this within the context of database B)sp_changedbowner 'YourUserAccountHere'

You'll need to edit the file paths for your environment, but this should do it for you once you determine you are dbo or have your DBA do this for you:

RESTORE DATABASE B FROM DISK = 'c:\a.bak'
WITH
MOVE 'A' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\B.mdf',
MOVE 'A_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\B_log.LDF',
REPLACE


Hopefully that helps.
Go to Top of Page
   

- Advertisement -