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
SET NOCOUNT ON SELECT 'ALTER LOGIN [' + loginname + '] DISABLE GO' FROM syslogins WHERE name NOT IN ('asql') and name not like '%#%' AND isntname = 0
SET NOCOUNT ON SELECT 'ALTER LOGIN [' + loginname + '] ENABLE GO' FROM syslogins WHERE name NOT IN ('asql') and name not like '%#%' AND isntname = 0