[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

In a Sql 2005 database how do you change dbo username

I am trying to change the dbo username on a sql database.

Under security, I have the user name as dbo and the login name as domain\username.

I want to change user name to another user name and the login name keep it the same.  How do I change that?  Thanks!
0
VBBRett
Asked:
VBBRett
1 Solution
 
Marten RuneCommented:
The DBO is a fixed user in every Database. I guess you can set SA as DBO, and then add the user, finally grant the user the role dbowner, and you ought to be fine.

T-SQL code below
-- Change DBO
use YourDBNameHere
GO
SP_ChangeDBOwner 'SA'
GO

-- Add User to Database
CREATE USER [Domain\user] FOR LOGIN [Domain\user]
GO

-- Grant DBOwner role
EXEC sp_addrolemember N'db_owner', N'Domain\user'
GO

//Marten
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now