User not valid?

  • Hi everyone,

    I have a user who has read/write permissions in database A and read permission in database B. Database A has a view X that reads info from database B. When the user tries to run the view in database A, she gets the following error:

    “Server user 'XXXXXXXX' is not a valid user in database 'B'.”

    Why is this happening?

    I checked the select statement in the view and all it is doing is selecting by joining some tables in database B.

  • Can she do anything in database B?  Have you ran sp_change_users_login 'Report' to see if the SID is correct?

    Derrick Leggett
    Mean Old DBA
    When life gives you a lemon, fire the DBA.

  • Try to drop the user from database B and re-grant him/her to access database B with proper permissions.

  • Try researching

    EXEC sp_change_users_login 'Auto_Fix', 'UserNameHere'

    More information in BOL



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • Thank you everyone. I'll let you know what I find out about this problem.

  • I'd go with

    exec sp_change_users_login 'Update_One', 'username'



    Shamless self promotion - read my blog http://sirsql.net

  • OK, just found out that the user is not in database B. When I go to EM, Security, Logins, and look at the user's database access, the user has access to the database B. But when I went to the database, Users, she was not listed in there. I added her to the database and now everything is fine. So it seems like sql server did half the job I asked it to do when I created this user.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply