My Tech Scrap
Flipkart.com

Translate

Share |

Friday, 25 April 2025

In Microsoft SQL Server, if you see a user under Database > Security > Users, but not under Server > Security > Logins, it means the database user exists, but its corresponding server-level login is missing.

 

This typically happens when a database is restored on a different server, and the associated login wasn't recreated on the new server.

🔧 Fixing the Issue: Create Login & Map to Existing User

You can't reset a password for a database user directly. Instead, you need to:

✅ Step 1: Create a new login at the server level

Use this T-SQL to create a server-level login that matches the database user:

CREATE LOGIN [UserName] WITH PASSWORD = 'YourNewPassword';

Replace UserName with the name shown under Database > Security > Users.

✅ Step 2: Map the login to the existing user in the database

Now, map the newly created login to the existing user:

USE [YourDatabaseName];
ALTER USER [UserName] WITH LOGIN = [UserName];