Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to lock database users

Status
Not open for further replies.

andreis

Programmer
Apr 19, 2001
169
US
Hi, is there a script that allows me to lock (prevent from logging in) all database users (both NT and SQL Server), and then enable them back? I can do ALTER LOGIN USERNAME DISABLED, but I have about 200 users, so I'd like to have a script...
 
Run the following query and copy and paste the results back into the SQL text box:

Code:
USE [master]
SELECT 'ALTER LOGIN ' +  [name] + ' DISABLE' FROM syslogins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top