none
The server principal 'username' already exists. RRS feed

  • Question

  • I've removed the username from the Security/Logins. Now I want to recreate with the following code.

    CREATE LOGIN [USERNAME] WITH PASSWORD=N'Ir5zfuLcdZWDZUyqZPdPBRtItc/cnqxBPAcTUITzoc=', 
    DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], 
    CHECK_EXPIRATION=ON, CHECK_POLICY=ON

    And I kept getting this error:

    Msg 15025, Level 16, State 1, Line 6
    The server principal 'USERNAME' already exists.


    So I ran this code:

    SELECT name  
    FROM master.sys.server_principals
    WHERE name = 'USERNAME'
    And in the 'name' column it does show 'USERNAME'. So I am assuming this means the user 'username' was not deleted from the master.sys.server_principals table, correct? If so, how do I totally remove it so that I can recreate them?

    • Edited by Charlie2 Friday, October 18, 2019 12:52 PM code didn't display correctly
    Friday, October 18, 2019 12:49 PM

All replies

  • Hi 

    Can you try running the below code and let me know how it goes.

    DROP LOGIN USERNAME;
    CREATE LOGIN [USERNAME] WITH PASSWORD=N'Ir5zfuLcdZWDZUyqZPdPBRtItc/cnqxBPAcTUITzoc=', 
    DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], 
    CHECK_EXPIRATION=ON, CHECK_POLICY=ON

    Hope this is helpful !!

    Thank you


    If this post helps to resolve your issue, please click the "Mark as Answer" of that post and/or click Answered "Vote as helpful" button of that post. By marking a post as Answered and/or Helpful, you help others find the answer faster.

    • Proposed as answer by Kris_SQL Friday, October 18, 2019 2:42 PM
    Friday, October 18, 2019 1:25 PM
  • I got this message:

    Msg 15434, Level 16, State 1, Line 6
    Could not drop login 'USERNAME' as the user is currently logged in.

    Friday, October 18, 2019 1:51 PM
  • Hi

    So, you are logging in with "USERNAME" due to which it is not being dropped. If you want to drop and recreate the USERNAME Login, try logging in with other login and try what you are willing to do.

    Hope you got the issue

    Thank you


    If this post helps to resolve your issue, please click the "Mark as Answer" of that post and/or click Answered "Vote as helpful" button of that post. By marking a post as Answered and/or Helpful, you help others find the answer faster.

    Friday, October 18, 2019 2:13 PM
  • I'm not logged in with that user name. I ran the exec sp_who2 and it shows this user name is in sleeping status. How do I remove them or take them out of sleeping?
    Friday, October 18, 2019 2:23 PM
  • You should see SP_ID in sp_who2 take that kill that as below

    KILL SP_ID

    Then have a retry

    Hope this is helpful !!

    Thank you


    If this post helps to resolve your issue, please click the "Mark as Answer" of that post and/or click Answered "Vote as helpful" button of that post. By marking a post as Answered and/or Helpful, you help others find the answer faster.


    Friday, October 18, 2019 2:25 PM
  • Okay for some reason it was reading the users from another database that I recently connected to and disconnect. So, I got that cleared. However, I got the following error:

    Msg 102, Level 15, State 1, Line 13
    Incorrect syntax near 'GO'.

    For this code:

    USE [master]
    GO
    
    CREATE LOGIN [USERNAME] WITH PASSWORD=N'Ir5zfuLcdZWDZUyqZPdPBQQtItc/cnqxBPAcTUITzoc=', 
    DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], 
    CHECK_EXPIRATION=ON, CHECK_POLICY=ON

    Friday, October 18, 2019 2:30 PM
  • Okay, I got it working now. I remove the GO and it seems to created now. Thank you for your help.
    Friday, October 18, 2019 2:33 PM
  • Great!!

    Please click the "Mark as Answer" of that post and/or click Answered "Vote as helpful" button of that post. By marking a post as Answered and/or Helpful, you help others find the answer faster.

    Thank you


    If this post helps to resolve your issue, please click the "Mark as Answer" of that post and/or click Answered "Vote as helpful" button of that post. By marking a post as Answered and/or Helpful, you help others find the answer faster.


    Friday, October 18, 2019 2:34 PM