--1、禁用启用账号账号
set nocount on SELECT 'ALTER LOGIN ' + name + ' ENABLE' FROM master.sys.server_principals WHERE name in ('loginname') and is_disabled=0
--2、KILL主机上的应用程序账户进程
SELECT 'KILL ' + CAST(SPID AS VARCHAR) FROM master.sys.sysprocesses WHERE loginame in ('loginname')
--3、查看账号连接
select loginame,count(0) as [count] from sys.sysprocesses WHERE loginame in ('loginname') group by loginame