Prevents a Microsoft® Windows NT® user or group from connecting to Microsoft SQL Server™.
sp_denylogin [@loginame =] 'login'
0 (success) or 1 (failure)
sp_denylogin can be used only with Windows NT accounts in the form Domain\User, for example London\Joeb. sp_denylogin cannot be used with SQL Server logins added with sp_addlogin.
Use sp_grantlogin to reverse the effects of sp_denylogin and allow the user to connect.
sp_denylogin cannot be executed within a user-defined transaction.
Only members of the securityadmin or sysadmin fixed server roles can execute sp_denylogin.
This example prevents user Corporate\GeorgeW from logging in to SQL Server.
EXEC sp_denylogin 'Corporate\GeorgeW'
Or
EXEC sp_denylogin [Corporate\GeorgeW]
Denying Login Access to Windows NT Accounts | sp_revokelogin |
sp_grantlogin | System Stored Procedures |