Avatar billede borrisholt Novice
13. april 2004 - 12:07 Der er 2 kommentarer og
3 løsninger

Skift database Owner

Jeg har en database som står uden Owner, og den vil jeg gerne have sat en Owner på.

Jeg har søgt lidt på Eksperten og har fundet der her http://www.eksperten.dk/spm/173285,  hvor han basalt set siger brug sp_changeobjectowner. Men den går på en tabel, ikke en database.

Mit spørgsmål går ganske simpelt på : Hvordan ændre jeg Owner på en HEL database ?

Jens B
Avatar billede slash Nybegynder
13. april 2004 - 12:11 #1
Kør denne fra QA.... stå under DB'en hvor du vil ændre owner....
EXEC sp_changedbowner 'KLYT'
Avatar billede mountmedia Nybegynder
13. april 2004 - 12:12 #2
sp_changedbowner
Changes the owner of the current database.

Syntax
sp_changedbowner [ @loginame = ] 'login'
    [ , [ @map = ] remap_alias_flag ]

Arguments
[@loginame =] 'login'

Is the login ID of the new owner of the current database. login is sysname, with no default. login must be Microsoft® SQL Server™ login or a Microsoft Windows NT® user that already exists. login cannot become the owner of the current database if it already has access to the database through an existing alias or user security account within the database. To avoid this, drop the alias or user within the current database first.

[@map =] remap_alias_flag

Is the value true or false, which indicates whether existing aliases to the old database owner (dbo) are mapped to the new owner of the current database or dropped. remap_alias_flag is varchar(5), with a default of NULL, indicating any existing aliases to the old dbo are mapped to the new owner of the current database. false indicates that existing aliases to the old database owner are dropped.

Return Code Values
0 (success) or 1 (failure)

Remarks
After sp_changedbowner is executed, the new owner is known as the dbo user inside the database. The dbo has implied permissions to perform all activities in the database.

The owner of the master, model, or tempdb system databases cannot be changed.

To display a list of the valid login values, execute the sp_helplogins stored procedure.

Executing sp_changedbowner with only the login parameter changes database ownership to login and maps the aliases of users who were previously aliased to dbo to the new database owner.

Permissions
Only members of the sysadmin fixed server role or the owner of the current database can execute sp_changedbowner.

Examples
This example makes the user Albert the owner of the current database and maps existing aliases to the old database owner to Albert.

EXEC sp_changedbowner 'Albert'
Avatar billede slash Nybegynder
13. april 2004 - 12:12 #3
Virker vist kun på SQL2000 med nyeste SP!
Avatar billede slash Nybegynder
13. april 2004 - 12:54 #4
funger det?
Avatar billede borrisholt Novice
13. april 2004 - 13:16 #5
Det fungerer perfekt !!!!

Jens B
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester