Warning: Undefined variable $ub in /home/sgso7sed/public_html/wp-content/plugins/advanced-page-visit-counter/public/class-advanced-page-visit-counter-public.php on line 148

Warning: Undefined variable $ub in /home/sgso7sed/public_html/wp-content/plugins/advanced-page-visit-counter/public/class-advanced-page-visit-counter-public.php on line 160
Change DB owner SQL Server Monitoring • SQL Server

Categories:

Need to change database owner programmatically?

-- check the owner of the database
select suser_sname(owner_sid) from sys.databases where name = 'db_name'

-- change DB owner
EXEC sp_changedbowner 'sa'

-- if the first doesn't work
EXEC dbo.sp_changedbowner @loginame = 'sa', @map = false

Tags:

Comments are closed