set nocount on --exec sp_addlogin 'joeuser', '', 'tempdb', 'us_english', 0x8BB4145DA75DED43BF4E96440AA3438C --sql logins select cast('exec sp_addlogin ''' + cast(name as varchar(20)) + ''',''password'',''' + cast(db_name(dbid) as varchar(20)) + ''',''' + language + ''',' as varchar(75)) , sid from sysxlogins where name is not null and name <> 'sa' and password is not null --windows logins select 'exec sp_grantlogin [' + rtrim(ltrim(name)) + '] exec sp_defaultdb [' + rtrim(ltrim(name)) + '], [' + rtrim(ltrim(db_name(dbid))) + ']' from sysxlogins where name is not null and name <> 'sa' and password is null print 'logins added, set passowrd for all SQL Logins now.'