Saturday, February 25, 2012

Cant copy database, strange error

I'm trying to copy a database from my web host to local Sql Server 2005 instance using the Copy Database wizard. I get this error:

An exception occurred while executing a Transact-SQL statement or batch.

Server user 'celestine' is not a valid user id database 'db2'.

However, 'db2' isn't the database I was trying to copy! I am trying to copy db1, but this error is complaining about db2, which is in fact somebody else's database that I don't have a login for. Why am I getting an error about db2 when I'm not trying to do anything with db2?

I can however export the tables from db1 just fine using Export. But then I have to go back and generate script to re-create the stored procs, views, etc., so it is rather tedious to do it that way.

This may be possible. For example if there is a view in db1 which references a table in db2, and the celestine login does not have access to db2, you may encounter this error.

So to avoid such issue, you can move/copy database by taking a full backup of the source database and then restore it on the destination server.

|||

Good idea but -- No, this is not the case. This is a shared hosting situation, the 2nd database is owned by someone else, I have absolutely no access to it at all. There is no relationship whatsoever between the databases.

I can't do a backup/restore either because I don't have access to the remote filesystem.

|||

Urgh...that's really a trouble. Then check whether your login has sufficient permissions to perform copy database task:

Required permissions

For the Copy Database Wizard to work, you must have the correct permissions, depending on how you are copying the database, as follows:

For the Detach and Attach Method, you must be a member of thesysadmin fixed server role on the both source and destination servers.

|||Right. But a) I do have correct permissions for both source/destination for the database I'm trying to copy, and b) The error is not pertaining to the database I want to copy. The error mentions a different database, that I have zero permissions for, that I will never have permissions for, that I don't want permissions for. I am trying to copy db1 and the error says "you don't have permissions for db2". Why is it even checking anything for db2?

No comments:

Post a Comment