5

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?

2 Answers 2

6

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] 
Sign up to request clarification or add additional context in comments.

3 Comments

Can you elaborate on why this workaround does not work for you?
When I create login1 in masterdb I am unable to login with that account. It was saying: The server principal "login1" is not able to access the database "master" under the current security context. Cannot open user default database. Login failed. Login failed for user 'login1'. (.Net SqlClient Data Provider)
Sorry, didn't realize this account needed to connect to the master db in addition to the user db. I added a line to create a user in the master db for that same login. Does this work for you?
-3

You need change a database owner 1. Create Login1 (without user in your DB) 2. In your db exec script:

sp_changedbowner 'Login1' 

So user [dbo] will automatic link to [login1]

1 Comment

SQL Azure does not support this store procedue. You would get error message: Could not find stored procedure 'sp_changedbowner'.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.