Deleting Security->Logins on SQL 2005 that are not mapped to a database user?

In my demoenvironment I handle great deals of SQL data sources. Each data source has great deals of Users, which are connected to divide Security - >Logins on the web server.

With time I maintain winding up with several (like hundreds) of orphans Security - >Logins that are not connected to any kind of users in any one of the data sources.

Exists any kind of SQL declarations I can go to go down the extra Logins - i.e. the logins that have no mappings to data source users?

1
2022-06-07 14:34:03
Source Share
Answers: 2

i would certainly recommend constructing a select declaration that links the person data source sysusers table to the master. sysxlogins.

several of the system procs you intend to discover are sp_MShasdbaccess and also sp_validatelogins.

1
2022-06-07 15:50:08
Source

Use sp_droplogin (or Management Studio)

Is there a subtext to your inquiry i.e. just how to you go down just logins that aren't connected to a data source customer? If so I assume (though I would certainly attempt it to ensure) that sp_droplogin will just delete logins that are not mapped to a db customer and also will certainly fall short if they are mapped.

JR

0
2022-06-07 14:57:30
Source