SQL Server Script to disable/enable all user accounts

The will create the syntax used to disable all SQL Server account.

SET NOCOUNT ON
SELECT
'ALTER LOGIN [' + loginname + '] DISABLE
GO'
FROM syslogins
WHERE name NOT IN ('asql') and name not like '%#%'
AND isntname = 0
The will create the syntax used to enable all SQL Server account.
SET NOCOUNT ON
SELECT
'ALTER LOGIN [' + loginname + '] ENABLE
GO'
FROM syslogins
WHERE name NOT IN ('asql') and name not like '%#%'
AND isntname = 0


Leave a comment or a question in the comment area bellow if you fell like


Be a sport and

Search

Loading... Please wait

Subscribe to our Newsletter

Be a sport and

x