I am in the middle of a large conversion from two slow physical servers into a screaming fast single server. During this process I have to map multiple databases to various user accounts. I can use the below syntax to perform this function one user at a time:
alter authorization on database::CTGCUSTOM to ALESTETMW ;
However I cannot figure out how to do this for multiple users. I have over 800 users I need to map and having multiple lines like below does not work
alter authorization on database::CTGCUSTOM to ALESTETMW ; alter authorization on database::CTGCUSTOM to ALLPAUTMW ; alter authorization on database::CTGCUSTOM to ALNSECTMW ; alter authorization on database::CTGCUSTOM to ALSJERTMW ; alter authorization on database::CTGCUSTOM to ANDDOUTMW ;
Can anyone show me how to do this for multiple users?
I must admit that I am a little confused by your example. Each of those statements would change the ownership of the database to a different person, which wipes away the effect of the previous statement. That is not what you are trying to do, is it?
No its not. It's the same effect if you went into the main Security\Logins and clicked user mappings for a specified user. You can then check which databases that user should be mapped to. When you select a database SQL will automatially create that user account under the security folder of the database you selected.