Discussion:
user as dbo in all databases
(too old to reply)
unknown
2009-11-03 16:24:57 UTC
Permalink
ASE 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
Mark A. Parsons
2009-11-03 20:05:16 UTC
Permalink
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 unknown
ASE 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
Loading...