Alter multiple Logins through SQL I am trying to change the following properties for SQL users to disable password complexity and expiration.

Using:

ALTER LOGIN xx WITH
CHECK_EXPIRATION=OFF, 
CHECK_POLICY=OFF
GO


Where 'xx' is an exact username works perfectly.
 
However, I would like to update an entire group of users that match a string such as:

SELECT FROM sys.sql_logins where is_policy_checked = '1' and name like '%cpsuser%'


So I attempted: 

ALTER LOGIN FROM sys.sql_logins where is_policy_checked = '1' and name like '%cpsuser%' WITH
CHECK_EXPIRATION=OFF, 
CHECK_POLICY=OFF
GO


But get an error that SQL doesn't recognize 'FROM'.

Is my Logic incorrect?
This is MySQL 2008.
The following query will provide a list of statements you can copy-and-paste into a new query window if you need to perform this task once:

SELECT 'ALTER LOGIN ' + QUOTENAME(sp.name) + '
    WITH CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF;'
    , *
FROM sys.server_principals sp
WHERE sp.type_desc = 'SQL_LOGIN'
    AND sp.is_disabled = 0
ORDER BY sp.name;


If you need to do this a lot, you could use dynamic SQL like this:

DECLARE @cmd NVARCHAR(MAX);

DECLARE cur CURSOR LOCAL FORWARD_ONLY STATIC
FOR
SELECT 'ALTER LOGIN ' + QUOTENAME(sp.name) + '
    WITH CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF;'
FROM sys.server_principals sp
WHERE sp.type_desc = 'SQL_LOGIN'
    AND sp.is_disabled = 0
ORDER BY sp.name;

OPEN cur;
FETCH NEXT FROM cur INTO @cmd;
WHILE @@FETCH_STATUS = 0
BEGIN
    PRINT (@cmd);
    --EXEC sp_executesql @cmd; /* uncomment this to actually modify logins */
    FETCH NEXT FROM cur INTO @cmd;
END
CLOSE cur;
DEALLOCATE cur;


The standard warnings apply about doing things like this in an automated fashion.  Test it in a non-production environment first, and roll this out to production with extreme caution.