The 'easy' method is to generate a 'sp_addalias' invocation for each target database. A couple ideas come to mind:
1 - select 'exec '+name+'..sp_addalias....' from master..sysdatabases where name in <list_of_target_dbs>; then
cut-n-paste the generated 'exec/sp_addalias' commands into an isql session for execution
2 - write a batch process (or stored proc) which cursors through a list of databases (pulled from master..sysdatabases)
and runs sp_addalias in each selected database; I find it easier to define the cursor like such:
select name+'..sp_addalias' from master..sysdatabases where ...
fetch the cursor results into a (var)char variable:
fetch cursor into @cmd
and then execute like such:
exec @cmd <arg1>,<arg2>
---------------
'course, this all gets more complicated if the user account in question is already a user in the database, aliased to
some other user in the database, or owns objects in the database.
Post by unknownASE 12.5x/15.x
Hi,
I need to set a user account to DBO in all the application
DB's on my server. What is the easiest way to do this? I
can't assign sa_role to this account.
Thx,
rick_806