Can't create users -- permissions issue

  • Hey guys . . .

    My computer was hit with a virus last week, so I had to wipe the drive and rebuild. I've ben trying to reinstall and rebuild everything that I had before.

    One of them is SQL 2008. I'm trying to recreate my staging database environment locally on my machine. I went to the database server, generated a script, and tried to run it locally on my machine.

    When I run the script, I get the following when I try to create users (user and schema names changed to protect the innocent):

    Msg 15007, Level 16, State 1, Line 2

    'UserName' is not a valid login or you do not have permission.

    This line is generating the error:

    CREATE USER [UserName] FOR LOGIN [UserName] WITH DEFAULT_SCHEMA=[SchemaName]

    This is happening regardless of the user name I'm trying to create.

    I figure it's a permissions issue somewhere, but I can't figure out where to look. BOL hasn't been very helpful (although I'm still looking).

    Can one of you point me in the right direction?

    Thanks, guys!

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • It’s your own system so I am asking it, Are you not using sa login for running the scripts?

  • What are you logged in as? SQL login or windows login? What permissions does that login have?

    Does the login 'UserName' exist?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Dev (1/4/2012)


    It’s your own system so I am asking it, Are you not using sa login for running the scripts?

    I'm using my Windows login, which should have sa permissions (or so I thought).

    I'll give it another shot with the sa login.

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • Well, I tried it with the sa login. No dice; I'm getting the same thing.

    GilaMonster (1/4/2012)


    Does the login 'UserName' exist?

    No; in fact, I'm trying to create it. This is what's generating the error.

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • CREATE USER [UserName]

    FOR LOGIN [UserName]

    WITH DEFAULT_SCHEMA=[SchemaName]

    Does the login & schema exist?

  • When you rebuilt, and resinstalled, I assume, did you "add Current User" as an administrator? That's easy to miss.

  • Steve Jones - SSC Editor (1/4/2012)


    When you rebuilt, and resinstalled, I assume, did you "add Current User" as an administrator? That's easy to miss.

    Yeah, that I did remember to do.

    Dev and Gail pretty much gave it to me -- the login didn't exist. For some reason, I was equating "login" with "user." Oops. :blush:

    As always, thanks for your help, guys!

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • Ray K (1/4/2012)


    Well, I tried it with the sa login. No dice; I'm getting the same thing.

    GilaMonster (1/4/2012)


    Does the login 'UserName' exist?

    No; in fact, I'm trying to create it. This is what's generating the error.

    If the login doesn't exist, you'll first need to create it with CREATE LOGIN, then switch to the specific DB and run CREATE USER ... FOR LOGIN ...

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Ray K (1/4/2012)


    Steve Jones - SSC Editor (1/4/2012)


    When you rebuilt, and resinstalled, I assume, did you "add Current User" as an administrator? That's easy to miss.

    Yeah, that I did remember to do.

    Dev and Gail pretty much gave it to me -- the login didn't exist. For some reason, I was equating "login" with "user." Oops. :blush:

    As always, thanks for your help, guys!

    Sometimes, more often than not, the error message is very clear as to what the underlying issue is πŸ˜‰

  • Ray K (1/4/2012)


    Steve Jones - SSC Editor (1/4/2012)


    When you rebuilt, and resinstalled, I assume, did you "add Current User" as an administrator? That's easy to miss.

    Yeah, that I did remember to do.

    Dev and Gail pretty much gave it to me -- the login didn't exist. For some reason, I was equating "login" with "user." Oops. :blush:

    As always, thanks for your help, guys!

    Attending night calls too often? πŸ˜‰

    Good to hear that it’s sorted.

  • Dev (1/4/2012)


    Ray K (1/4/2012)


    Steve Jones - SSC Editor (1/4/2012)


    When you rebuilt, and resinstalled, I assume, did you "add Current User" as an administrator? That's easy to miss.

    Yeah, that I did remember to do.

    Dev and Gail pretty much gave it to me -- the login didn't exist. For some reason, I was equating "login" with "user." Oops. :blush:

    As always, thanks for your help, guys!

    Attending night calls too often? πŸ˜‰

    ?????????

  • Guess the caffeine didn't kick in. This is one of those days when I wish coffee pots came with octane ratings. πŸ˜‰

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • Ray K (1/4/2012)


    Guess the caffeine didn't kick in. This is one of those days when I wish coffee pots came with octane ratings. πŸ˜‰

    Alcool is very effective as fuel πŸ˜€

  • Ray K (1/4/2012)


    Guess the caffeine didn't kick in. This is one of those days when I wish coffee pots came with octane ratings. πŸ˜‰

    LOL... Remi also need it :hehe:

Viewing 15 posts - 1 through 15 (of 23 total)

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