Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect an existing SQL Server login to an existing SQL Server database user of same name

Tags:

sql

sql-server

People also ask

How do I connect to SQL Server with a different user?

The quick solution is to hold the Shift-key while right clicking the SSMS shortcut in the start menu. Then the 'Run as different user' option appears, which allows you to enter different credentials.

What is the difference between login and user in SQL Server?

A login provides to a user or application the ability to connect to a SQL Server instance, whereas a database user provides the login rights to access a database. Each database a login needs access to will require a database user to be defined, except when a login has been given sysadmin rights.


The new way (SQL 2008 onwards) is to use ALTER USER

ALTER USER OrphanUser WITH LOGIN = correctedLoginName;

I think it's sp_change_users_login. It's been a little while, but I used to do that when detaching and reattaching databases.


I've used the sp_change_users_login procedure to accomplish, I think, that scenario.