MSSQL "Ghost"-user

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

MSSQL "Ghost"-user

Post by ^rooker »

[PROBLEM]
When reimporting a database backup with user information still stored in it, it might happen that the restored database ends up with some "ghost users" which do NOT appear in the Enterprise Manager GUI.
The problem with those accounts is, that you cannot use them to login, but if you try to re-assign the same account to the reimported DB, an error appears saying that the user IS already assigned.

[SOLUTION]
Use an SQL Query tool, connect to the affected database and execute some of the following commands:

-------------------------------------------------------
EXEC sp_revokedbaccess 'username'
EXEC sp_dropuser 'username'
EXEC sp_droplogin 'username'
-------------------------------------------------------

(of course: replace 'username' with the name of the user you want to remove)
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

General MSSQL user-information

Post by ^rooker »

to get information about any user assigned to the current database, use:

---------------------------------------
EXEC sp_helpuser 'username'
---------------------------------------
Post Reply