• PHXHoward (8/23/2012)


    Thanks for the example.

    I have made a script to do what I believe you indicated.

    DECLARE @cmd1 varchar(500), @cmd2 varchar(500), @cmd3 varchar(500)

    SET @cmd1 = 'print ''[?]'''

    SET @cmd2 = 'IF ''[?]'' NOT IN (''master'', ''model'', ''msdb'', ''tempdb'') alter authorization on database::[?] to [domain/login]'

    SET @cmd3 = 'IF ''[?]'' NOT IN (''master'', ''model'', ''msdb'', ''tempdb'') exec sp_addrolemember ''db_owner'', [domain/login]'

    EXEC sp_MSForEachDB @command1=@cmd1, @command2=@cmd2 , @command3=@cmd3

    cmd2 puts the checkbox next to the database in the login properties screen.

    ALTER AUTHORIZATION is changing the ownership of the databases in question. You want to create a user in each database for each login and assign db_owner to each user.