Search code examples
sql-serverazure-sql-databasedatabase-project

The parameter PASSWORD cannot be provided for users that cannot authenticate in a database


When I log in to azure portal select my SQL Database -> Tools -> QueryEditor and enter:

ALTER USER MyUser WITH Password = '**********'

I get the error:

Failed to execute query. Error: The parameter PASSWORD cannot be provided for users that cannot authenticate in a database.

I've created the user in Visual Studio Database Project in MyUser.sql (Build Action=Build):

CREATE USER [My_User] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo];

Why I'm getting the message?

Is it possible to create the User in Database Project so that I will specify the password later (not is source code)?


Solution

  • Your user is not a contained database user that can be authenticated by database. This is because you did not create it with syntax

    CREATE USER user_name WITH PASSWORD = 'strong_password';
    

    What you've created is a "traditional" user without login, in "traditional" model user cannot have a password, only the corresponding login can. But your user has no corresponding login as it was created without login, so you cannot change a password at all.

    Here you can find more detailes about contained database urers: Contained Database Users