Share via

Unable to add a machinename to SQL > Security > Login

Payne, Scott 41 Reputation points
2025-11-13T19:59:35.02+00:00

We have successfully added machine names to the SQL Server running on an Azure VM, and they are functioning perfectly. However, when attempting to add a particular server, we receive a message indicating that it is already added. When we try to list it, we get a message stating that it doesn't exist. Attempts to add it again result in the same "already added" message. Our DBA then tries to remove the server but encounters a message saying it doesn't exist. Despite repeated efforts to add it, we consistently receive the "already added" notification. After running a query to check for orphaned SIDs, no such SIDs appear.

We are seeking an alternative query or PowerShell command to remove or repair the invisible machine name. Ultimately, we need to establish a

SQL Server | Other
0 comments No comments

Answer recommended by moderator
  1. Akhil Gajavelly 1,725 Reputation points Microsoft External Staff Moderator
    2025-11-14T06:31:53.51+00:00

    Hi @Payne, Scott ,

    This happens when SQL Server has a stale or partially dropped machine login in master even though it’s not visible.

    Run this to confirm and remove it:

    SELECT principal_id, name, sid

    FROM sys.server_principals

    WHERE name = 'MachineName$';

    If a principal_id appears, force-drop it:

    DROP LOGIN [MachineName$];

    If nothing appears, check for hidden/orphaned permissions:

    SELECT *

    FROM sys.server_permissions

    WHERE grantee_principal_id NOT IN (SELECT principal_id FROM sys.server_principals);

    If entries exist → remove them using the principal_id, then add the login again.

    If still stuck, run:

    DBCC CHECKDB (master);

    to rule out corruption in master.

    This will clean the invisible login and allow adding the machine name again.

    Thanks,
    Akhil.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.