SQL Server logins password not to expire option instance level for all logins ?
Is there any command , SQL server logins password not to expire option instance level for all logins ? Similar like oracle profile no expire.(unlimited)? OR Is it possible with SQL Server Policy based management? I know each login how to alter command. But looking one configuration or command to not to expire password for all logins? Alter login loginName with check_policy=off Thanks in advance
No way to do that for all logins in a single command. Since you know the command, a good approach would be to go through each login and set it. You could use a cursor from T-SQL or PowerShell to make it happen.
USE [master] GO SET NOCOUNT ON DECLARE @LoginName NVARCHAR(200) DECLARE @max INT DECLARE @i INT DECLARE @SQL NVARCHAR(MAX) CREATE TABLE #T (ID INT IDENTITY(1,1), LoginName NVARCHAR(200)) INSERT INTO #T SELECT name FROM sys.server_principals WHERE type = 'S' AND name not in ('sa') AND name not like '##%' SELECT @i = MIN(ID), @max = MAX(ID) FROM #T WHILE @i <= @max BEGIN SELECT @LoginName = LoginName FROM #T WHERE ID = @i SET @SQL = 'ALTER LOGIN '+@LoginName+' WITH CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF ' PRINT @SQL EXEC(@SQL) SET @i += 1 END DROP TABLE #T