Lesson Learned #29: Getting the error message : The login already has an account under a different user name while importing a bacpac
Published Mar 13 2019 06:46 PM 4,114 Views
First published on MSDN on Aug 10, 2017
Today, I worked in a service request where our customer got  the error message: Msg 15063, Level 16, State 1, Line 1 The login already has an account under a different user name, each time that they are importing a bacpac file.

Analyzing the situation, I saw that the bacpac file was generated in another Azure SQL Database Server and our customer is trying to import into another Azure SQL Database Server.

Normally, this error message means that you have a database user already mapped to a login. But in this case there is a new database so, this situation should not be occurred.

I was able to reproduce the issue with the following combination of factors:

  • The Bacpac came from a Azure SQL Database where the administrator user has the name MyUser and the user of the database has the name MyUserA associated to a login.

  • The target server has administrator login with name MyUserA.


At the moment of the import process our customer got the error Msg 15063, Level 16, State 1, Line 1 The login already has an account under a different user name because at the moment of the execution of CREATE USER [MyUserA] FOR LOGIN [MyUserA] by the import process, even when a new database is generating, due to is not possible to create a user that is associated with the administrator login.

In this situation, a contained user will be better than using a user with login mapping.

Enjoy!
1 Comment
Copper Contributor

I am having a similar error in deploying from a development SQL Server database to a production server of Azure SQL Server using bacpack. It creates the DB but fails at updating. 

Version history
Last update:
‎Mar 13 2019 06:46 PM
Updated by: