# Copy database, problem with not existing principal

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

Cannot find the principal 'MVGSQL01\itsac', because it does not exist or you do not have permission


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:

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.


-
updated answer for you. –  Craig Efrein Jul 15 '13 at 11:40

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

USE [master]
GO
CREATE LOGIN [NEWCOMPUTERNAME\itsac] FROM WINDOWS WITH DEFAULT_DATABASE=[mydatabase]
GO

USE [mydatabase]

CREATE USER [NEWCOMPUTERNAME\itsac] FOR LOGIN [NEWCOMPUTERNAME\itsac]
GO


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.

-
Tried adding a new user (in Windows 8). All I get to input is an email address. Sounds like a real server administrator here doesn't it! Also, I'm not sure I dare change any settings on the source database, as it's a company (live) database server. I can of course see if the user itsac is of any importance. But why does that principal matter? The only user that is needed to access the database is another one, one that I have created a login for in the destination server. For the same reason (no change to the source) the suggestions in the link probably wont be of any help. –  SamiHuutoniemi Jul 12 '13 at 14:29
Can you be more specific about how you are copying the database? Since you are saying that you can't use backups, what are you using exactly? –  Craig Efrein Jul 12 '13 at 14:33
I'm using the Tasks -> Copy Database in SSMS. –  SamiHuutoniemi Jul 12 '13 at 15:14
I will try the same operation and let you know how it goes –  Craig Efrein Jul 12 '13 at 15:35
Thanks for helping out! Right now I scripted the database schema and generated a copy from that. Now I'm copying all necessary tables by generating scripts with data only. This seems to work well, but it doesn't void the need for a proper way to do it. This way is a lot of manual work. –  SamiHuutoniemi Jul 12 '13 at 15:45

I have never had luck with "copy database" in SSMS. In fact, it has always been more cumbersome. Can the administrator of that server create an FTP or fileshare and temporarily grant you access to it? The Admin could then dump a backup file there, that you can grab and restore.

-