Want to remove an existing user mapping for a login.

  • In SQL Server 2012, I want to remove (programmatically in C# or via SQL command line) a login mapping to a user. I have a login that is mapped to a database user and I want to remove that mapping without removing the login, user or database.

  • looks like it cannot be done;

    my knee jerk reaction was to see if ALTER USER supported WITHOUT LOGIN, which it does not;

    my next idea was to ALTER USER WITH LOGIN = NULL, which is also not supported.

    --syntax errors:

    ALTER USER SampleUser WITHOUT LOGIN

    ALTER USER SampleUser WITH LOGIN = NULL

    i think it's better to drop and recreate the user without login? then you can alter thema nd remap them to the login?

    DROP USER SampleUser

    CREATE USER SampleUser WITHOUT LOGIN

    maybe you could move the user out of it's existing roles so it effectively cannot do anything in the database instead?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks. The DROP USER will work for me.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply