In this blog you will find ASP.NET 3.5 articles and some code samples. These code samples are created by me and should be working. Thanks for visiting my blog! Happy Dot Netting

Friday, July 18, 2008

Set SQL Password Policy OFF for set of users at once

 

Declare @MinUID as integer

-- Query ‘select * from sysusers’ and choose the minimum UID from where you would like to set password policy off

select @MinUID = 4

Declare @MaxUID as integer

-- Choose the maximum UID up to where you would like to set password policy off

select @MaxUID= 16384

declare @NextLoginName as varchar(30)

declare @strQuery as varchar(50)

 

DECLARE Login_name CURSOR FOR

select name from sysusers where   uid > @MinUID and uid < @MAxUID order by name

 

open login_name

 

fetch next from login_name into @NextLoginName

While @@fetch_status = 0

      Begin

            --print @NextLoginName

            set @strquery = 'alter login ' +  @NextLoginName + ' with check_policy = off'

            exec (@strquery )

      fetch next from login_name into @NextLoginName

      end

 

close login_name

deallocate login_name

No comments: