/*
This script is designed to find the logins those are locked out in the database Server.
It is tested to run on:
SQL 2000 - NO (Login lock feature was not introduced in this SQL version)
SQL 2005 - YES
SQL 2008 - YES
*/
set nocount on
declare Cur_locked_login cursor for select name from master..syslogins order by name
declare @loginname nvarchar(100)
open Cur_locked_login
fetch next from Cur_locked_login into @loginname
while @@FETCH_STATUS >= 0
begin
if (select LOGINPROPERTY(@loginname,'islocked')) =1
print 'Login -> ' + @loginname +' is LOCKED'
fetch next from Cur_locked_login into @loginname
end
close Cur_locked_login
deallocate Cur_locked_login
this is relevant for my current job.. keep updating.
ReplyDeleteSanjay -
DeleteThank you for your comments.. I will have more SQL stuffs soon in my blog.. Keep track of it... You can comments on blogs if you need my help. Suggestions are always welcomed.
I hope you like my blog and it helps you..
I will provide much more relevant blogs related to your interest.
Thank you,
Bharat
DBA SQL Server
MCTS ceritified