Zmiana db ownera w SQL Server na sa.

0

Jestem ownerem bazy DB (utworzyłem ją), chcę zmienić jej ownera na sa poleceniem:

USE [DB]
GO
ALTER AUTHORIZATION ON DATABASE::[DB] TO [sa]
GO

otrzymuję błąd:
Msg 15151, Level 16, State 1, Line 3
Cannot find the principal 'sa', because it does not exist or you do not have permission.

mam standardowe uprawnienia servera db_creator
do bazy DB mam tylko public i db_owner
do bazy master mam accesadmin

Proszę o pomoc.

0

Próbujesz to zrobić z użytkownika sa? Może użytkowania, z którego porabujesz to zorbić, nie ma uprawnień do tego.

0

Tomek Pycia
Próbuję to robić z użytkownika, który utworzył tę bazę.

0

Czyli prawdopodobnie nie masz do tego uprawnień. Zaloguj się na sa i wtedy próbuj to robić.

0

Ok. A jakich uprawnień do tego konkretnie potrzebuję? Chcę jako sa dodać takie uprawnienia temu użytkownikowi.

0

Obstawiam ze db_admin ale pewny nie jestem. W dokumentacji na pewno znajdziesz.

0

W tym cały problem.

Wyświetlam ownera jest nim użytkownik, którym próbuje zmienić ownera na sa

USE [master]
GO
SELECT suser_sname(owner_sid) 
FROM sys.databases 
WHERE name = 'DB'
GO

W dokumentacji mam:
db_owner Members of the db_owner fixed database role can perform all configuration and maintenance activities on the database, and can also drop the database in SQL Server. (In SQL Database and SQL Data Warehouse, some maintenance activities require server-level permissions and cannot be performed by db_owners.)

dlatego pytam dlaczego po wykonaniu poniższego skryptu, otrzymuję błąd skoro jestem db_owner bazy DB ?

USE [DB]
GO
ALTER AUTHORIZATION ON DATABASE::[DB] TO [sa]
GO

Msg 15151, Level 16, State 1, Line 3
Cannot find the principal 'sa', because it does not exist or you do not have permission.

Jestem laikiem proszę o wyrozumiałość. Może czegoś nie rozumiem :(

1

dbo na bazie nie może sobie dodać FULLa na cały serwer i wszystkie bazy
na każdej bazie jest jeden użytkownik typu sa
z tego użytkownika dopiero możesz swojemu dbo przypisać uprawnienia sa

2

Uprawnienia których potrzebujesz:

Requires TAKE OWNERSHIP permission on the entity. If the new owner is not the user that is executing this statement, also requires either, 1) IMPERSONATE permission on the new owner if it is a user or login; or 2) if the new owner is a role, membership in the role, or ALTER permission on the role; or 3) if the new owner is an application role, ALTER permission on the application role.

https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-authorization-transact-sql?view=sql-server-2017

1 użytkowników online, w tym zalogowanych: 0, gości: 1