title: Change Login name (Windows user) for an existing SQL user on the Database server
body: <p>We have a SQL 2012 database and our users are set up via Windows Authentication to connect to a specific database -  say DatabaseA.</p>
  
  <p>It looks like this: <strong>Windows user</strong> "<em>DomainA/abcd</em>", is mapped to a <strong>user</strong> "<em>abcd</em>" in DatabaseA, which has a default <strong>schema</strong>  "<em>abcd</em>" which in turn owns a bunch of tables. Remote users log into their laptops (as DomainA/abcd), connect via VPN and are able to query data from the SQL server (they pull data from their default schema, based on their Windows login).</p>
  
  <p>It all works fine, however, now we are moving to a new domain.</p>
  
  <p>Our users will be logging in as "DomainB/abcd" and when they try to connect to <em>their</em> tables on the server, no data is being returned since "DomainA/abcd" and "DomainB/abcd" are different users.</p>
  
  <p><strong>What am I trying to achieve:</strong> Can I get the DB user "abcd" which is currently mapped to Windows login "DomainA/abcd", to point to Windows login "DomainB/abcd". Is that even possible?</p>
  
  <p>If not, what are the alternatives. We want to avoid dropping the schema/tables and the user and then recreate everything again.</p>
  
  <p><strong>What have I tried:</strong> I tried <code>ALTER USER</code> and <code>sp_change_users_login</code> to no avail. </p>
  
  <p><code>ALTER USER [DomainB\abcd] WITH LOGIN = [abcd]</code> returns <code>Cannot remap user to login 'abcd', because the login is already mapped to a user in the database.</code> - Makes perfect sense.</p>
  
  <p><code>EXEC sp_change_users_login 'Update_One', 'abcd', 'DomainB\abcd'; GO</code> returns <code>Terminating this procedure. The User name 'abcd' is absent or invalid.</code> - <a href="https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-change-users-login-transact-sql?view=sql-server-ver15" rel="nofollow noreferrer">MSDN</a> says this could be used to map a db user to a new SQL login, no mention of a Windows login.</p>
  
  <p>I'm a member of the sysadmin role on the DB server, so I don't think that it is a permission issue.</p>