Reputation: 73
At work, I recently "inherited" a database and was told make a better one, which I have. Now I have to copy the users over, been searching, have found no easy way to this. Most of the methods involved drop the user, which I am told not to do. So, how can I add user to a new DB in SQL Server 2014 that already exists?
EDIT What I am really looking for here is adding an already existing user that already has access to a database to another database, most of the stuff I have looked at overly complicates what I see as a really simple task.
Upvotes: 2
Views: 3748
Reputation: 2053
Logins and users are very different things in SQL Server. There's a ton of very detailed write-ups on the subject so google/bing it. In short, you need to create the same user that existed in the original database in your new database. This user has to be mapped to the same login. An easy way is to script all the users from the original database (via SSMS) and run the scripts against your new database.
This SO post has a good high level description of logins & users that will help you understand how they work together: Difference between a User and a Login in SQL Server
You should also get very familiar with the content on https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql/overview-of-sql-server-security
Upvotes: 1