patternsqlMinor
Copy database, problem with not existing principal
Viewed 0 times
problemwithdatabaseprincipalexistingnotcopy
Problem
I'm trying to copy a database from a server to my laptop, using Management Studio. However, after about an hour of copying, I get the error
I do not have the option of using backups, as I do not have access to the file system on the source server.
I found something while searching on Google, that suggested I should do:
but if I change SEC_USER for ITSAC and Sec_User for itsac, I get almost the same error message:
Some advice would be appreciated!
Cannot find the principal 'MVGSQL01\itsac', because it does not exist or you do not have permissionI do not have the option of using backups, as I do not have access to the file system on the source server.
I found something while searching on Google, that suggested I should do:
CREATE LOGIN SEC_USER WITH PASSWORD = 'YourPassword'
Alter User Sec_User with login = SEC_USER;but if I change SEC_USER for ITSAC and Sec_User for itsac, I get almost the same error message:
Cannot alter the user 'itsac', because it does not exist or you do not have permission.Some advice would be appreciated!
Solution
The principal in the error you are seeing (MVGSQL01\itsac) is a Windows login from the computer MVGSQL01 and can't be created in SQL Server because it doesn't exist on the destination computer.
You would need to create a new Windows login on the computer you are copying your database to.
Then in SSMS using a new query window, you would run these two commands to add the login and then the database user for your new login
Note: Since the computer name of the principal (login) is different though, you will probably get the same error. Another option would be to remove the login (MVGSQL01\itsac) from SQL Server on MVGSQL01 temporarily and then copy the database to your laptop.
There is a stored procedure called sp_help_revlogin http://support.microsoft.com/kb/918992 that can be used to backup and or transfer your logins.
Updated 7/15/2013
In SSMS, when you launch the SQL Server Copy Database Wizard, you will eventually get to the Select Server Objects Screen, if you are copying to or from a remote server.
From there you can select which users you want or don't want to copy for the database you wish to copy.
And Then you get the Logins screen. Click on Copy only the selected logins and then select the logins you wish to copy. In your case, you will be excluding MVGSQL01\itsac.
You would need to create a new Windows login on the computer you are copying your database to.
Then in SSMS using a new query window, you would run these two commands to add the login and then the database user for your new login
USE [master]
GO
CREATE LOGIN [NEWCOMPUTERNAME\itsac] FROM WINDOWS WITH DEFAULT_DATABASE=[mydatabase]
GO
USE [mydatabase]
CREATE USER [NEWCOMPUTERNAME\itsac] FOR LOGIN [NEWCOMPUTERNAME\itsac]
GONote: Since the computer name of the principal (login) is different though, you will probably get the same error. Another option would be to remove the login (MVGSQL01\itsac) from SQL Server on MVGSQL01 temporarily and then copy the database to your laptop.
There is a stored procedure called sp_help_revlogin http://support.microsoft.com/kb/918992 that can be used to backup and or transfer your logins.
Updated 7/15/2013
In SSMS, when you launch the SQL Server Copy Database Wizard, you will eventually get to the Select Server Objects Screen, if you are copying to or from a remote server.
From there you can select which users you want or don't want to copy for the database you wish to copy.
And Then you get the Logins screen. Click on Copy only the selected logins and then select the logins you wish to copy. In your case, you will be excluding MVGSQL01\itsac.
Code Snippets
USE [master]
GO
CREATE LOGIN [NEWCOMPUTERNAME\itsac] FROM WINDOWS WITH DEFAULT_DATABASE=[mydatabase]
GO
USE [mydatabase]
CREATE USER [NEWCOMPUTERNAME\itsac] FOR LOGIN [NEWCOMPUTERNAME\itsac]
GOContext
StackExchange Database Administrators Q#46202, answer score: 4
Revisions (0)
No revisions yet.