Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the owner of a SQL Server database?

When I accidentally click on the Database Diagrams tab, I get one of the following errors:

Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.

--- or ---

The database does not have one or more of the support objects required to use database diagramming. Do you wish to create them?

What's the syntax for changing the owner of this database to 'sa'?

like image 942
Even Mien Avatar asked Apr 20 '09 18:04

Even Mien


People also ask

How do I add a database owner in SQL Server?

Open Microsoft SQL Management Studio Express. Navigate to Security > Logins > Right-click the db user and select Properties. In properties go to User Mappings. Click on the database and check that the options db_owner and Public are selected.

What is database owner in SQL Server?

The dbo, or database owner, is a user account that has implied permissions to perform all activities in the database. Members of the sysadmin fixed server role are automatically mapped to dbo.

How do I change the grantor in SQL Server?

Grantor is simply who granted the permissions to the grantee. You can change this by revoking the permissions and regranting it. Do the SIDs match up for intake on the database (query sys. database_principals in the database) and on the server for the login (query sys.

How do you change the ownership of a schema?

You must own the schema to use ALTER SCHEMA . To rename a schema you must also have the CREATE privilege for the database. To alter the owner, you must also be a direct or indirect member of the new owning role, and you must have the CREATE privilege for the database.


3 Answers

To change database owner:

ALTER AUTHORIZATION ON DATABASE::YourDatabaseName TO sa

As of SQL Server 2014 you can still use sp_changedbowner as well, even though Microsoft promised to remove it in the "future" version after SQL Server 2012. They removed it from SQL Server 2014 BOL though.

like image 109
Alex Aza Avatar answered Oct 04 '22 22:10

Alex Aza


to change the object owner try the following

EXEC sp_changedbowner 'sa'

that however is not your problem, to see diagrams the Da Vinci Tools objects have to be created (you will see tables and procs that start with dt_) after that

like image 35
SQLMenace Avatar answered Oct 04 '22 21:10

SQLMenace


This is a prompt to create a bunch of object, such as sp_help_diagram (?), that do not exist.

This should have nothing to do with the owner of the db.

like image 42
gbn Avatar answered Oct 04 '22 21:10

gbn