Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 script to drop login

Author  Topic 

rb1373
Yak Posting Veteran

93 Posts

Posted - 2004-12-30 : 10:22:39
Does anyone have a script to drop a login from a server? Below is what I had in mind. Thanks.

DECLARE @myLogin varchar(25)

SET @myLogin = 'MyLogin'

-- need logic to check if login exists
Begin
-- for each db (sp_MSforeachdb)
-- need logic to check if login exists
EXECUTE sp_revokedbaccess @myLogin

EXEC sp_droplogin @myLogin
End

nr
SQLTeam MVY

12543 Posts

Posted - 2004-12-30 : 10:36:53
the login maps to the user un he database via the sid.
if exists (select * from sysusers u, master..sysogins l where l.sid = u.sid and l.name = 'mylogin')

Then you would have to revoke the access for that user - not 'mylogin'.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -