Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Azure: How to alter dbo user with new login

In SQL Azure, I want to assign login name [login1] to user [dbo].

I am currently logged in with [login1] account, and try this:

ALTER USER [dbo] WITH LOGIN = [login1]

But it is saying:

Cannot alter the user 'dbo'.

I have also tried this:

ALTER AUTHORIZATION ON SCHEMA::[dbo] TO [login1]

But it is saying:

Cannot find the user 'login1', because it does not exist or you do not have permission.

I am able to create new table like [dbo].[MyTable], but can not see it in the table list even though it existed.

Any ideas?

like image 410
Minh Nguyen Avatar asked Oct 19 '22 22:10

Minh Nguyen


1 Answers

You can't re-map [dbo] to [login1], but you can add [login1] to the db_owner database role. For example:

-- in master db
CREATE LOGIN [login1] WITH PASSWORD = '{Some Password}'
CREATE USER [login1] FOR LOGIN [login1]

-- in user db
CREATE USER [login1] FOR LOGIN [login1]
ALTER ROLE [db_owner] ADD MEMBER [login1]
like image 74
tmullaney Avatar answered Oct 21 '22 22:10

tmullaney