title: How to check if the USER is already created in the database or not in SQL?
body: <p>Is there is a way that from it I can know if the user(<strong>not</strong> the login) is already created in the database? I mean the user not the login, since, I know how to check for the login. I need to check for the user that is created inside a specific DB &amp; a role assigned to it.</p>
  
  <p>This is the code for checking for the login:</p>
  
  <pre><code>SELECT name FROM sys.server_principals WHERE name = 'test_user'
  </code></pre>
  
  <p>but how about the user? Since I need to create the user and assign a role to it if its not created. Otherwise, I will continue without creating.</p>
  
  <p>Thanks</p>