How to check if the USER is already created in the database or not in SQL?

How about:

USE (your database you want to check the user's existence in)

SELECT * 
FROM sys.database_principals
WHERE name="(your user name to check here)"

sys.server_principals shows you the logins defined on the server level – sys.database_principals shows you the principals (e.g. user accounts) on a database level.

Leave a Comment