How can I update the roles for all logins using T-SQL?
You can use dynamic sql.

declare @sqltext nvarchar(max) = N''

-- here you are adding all the logins to dbcreator fixed server role ...
-- this is just an example to get you started ...adjust it as per your needs !!
select @sqltext += 'ALTER SERVER ROLE dbcreator ADD MEMBER '+QUOTENAME(name)+';'+char(10)+'go'+char(10) from sys.server_principals 
where type_desc ='SQL_LOGIN' -- only for sql logins 
and name &lt;&gt; 'sa' -- not sa
and name not like '##%' -- not special logins like certs etc 
and is_disabled = 0 -- not disabled 

print @sqltext 
--once you are fine with the output then uncomment below 
-- exec sp_executesql @sqltext -- this will actually run the sql !!