Assign a login to a user created without login (SQL Server)

后端 未结 6 1838
逝去的感伤
逝去的感伤 2021-01-31 07:52

I have got a user in my database that hasn\'t got an associated login. It seems to have been created without login.

Whenever I attempt to connect to the database with t

6条回答
  •  醉梦人生
    2021-01-31 08:06

    What kind of database user is it? Run select * from sys.database_principals in the database and check columns type and type_desc for that name. If it is a Windows or SQL user, go with @gbn's answer, but if it's something else (which is my untested guess based on your error message) then you have a different problem.


    Edit

    So it is a SQL-authenticated login. Back when we'd use sp_change_users_login to fix such logins. SQL 2008 has it as "don't use, will be deprecated", which means that the ALTER USER command should be sufficient... but it might be worth a try in this case. Used properly (it's been a while), I believe this updates the SID of the User to match that of the login.

提交回复
热议问题