Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Want to remove an existing user mapping for a login. Expand / Collapse
Author
Message
Posted Friday, November 16, 2012 3:25 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2012 9:09 AM
Points: 2, Visits: 2
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.
Post #1385873
Posted Friday, November 16, 2012 3:36 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:30 PM
Points: 12,895, Visits: 32,089
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1385875
Posted Monday, November 19, 2012 8:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 19, 2012 9:09 AM
Points: 2, Visits: 2
Thanks. The DROP USER will work for me.
Post #1386426
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse