How to Change the Ownership of a Database in SQL Server - SQL Server DBA Tutorial

In this video you will learn how to change owner of a database in SQL Server? video provides different following ways to do it.

1- How to change database owner using Store Procedure
2- How to change database owner using Alter Authorization statement.

Scripts:

Use Demo

--EXEC sp_changedbowner 'New Owner Login'
EXEC sp_changedbowner 'sa'

-- Changing database owner using Alter Authorization to Login [TECHBROTHERS\clusteradmin] 
ALTER AUTHORIZATION ON Database:: Demo TO [TECHBROTHERS\clusteradmin]



How to Change the Ownership of a Database in SQL Server - SQL Server DBA Tutorial


3 comments:

  1. USE [master]
    GO
    SELECT [name] AS dbname FROM sys.databases WHERE SUSER_SNAME(owner_sid) = 'USER_NAME_HERE'
    GO

    ReplyDelete
  2. TODAY I GOT MY DESIRED XMAS LOAN AMOUNT $520,000.00 FROM A RELIABLE AND TRUSTED LOAN COMPANY. IF YOU NEED A LOAN NOW EMAIL CONTACT drbenjaminfinance@gmail.com

    Hello, I'm here to testify of how i got my loan from BENJAMIN LOAN FINANCE(drbenjaminfinance@gmail.com) I don't know if you are in need of an urgent loan to pay bills, start business or build a house, they offer all kinds of loan. So feel free to contact Dr. Benjamin Owen he holds all of the information about how to obtain money quickly and painlessly without cost/stress via Email: drbenjaminfinance@gmail.com

    Consider all your financial problems tackled and solved ASAP. Share this to help a soul right now THANKS.

    ReplyDelete