Al Phaba
Al Phaba

Reputation: 6765

How to transfer the existing database users to a new ms sql server?

I have imported my database to a new ms sql server. This works but the logins are not working. They exists on the database itself but they are not available in the security->logins area of the ms sql server. I tried to create them manually there but receive the exception that they already exists on my database.

How can I achieve that these logins are active for my new ms sql server?

Thanks

Upvotes: 1

Views: 255

Answers (2)

Al Phaba
Al Phaba

Reputation: 6765

Found the solution which works for me

USE testdb;
GO
EXEC sp_change_users_login 'Auto_Fix', 'testuser', NULL, 'testpwd';
GO

Upvotes: 1

Dave Simione
Dave Simione

Reputation: 1441

Add the logins to the server, but don't associate them with the database. Then, run this:

USE [your database];
GO    
ALTER USER {user} WITH LOGIN={login};

Upvotes: 1

Related Questions