November 16, 2012 at 3:25 pm
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.
November 16, 2012 at 3:36 pm
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
November 19, 2012 at 8:28 am
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