SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Can't create users -- permissions issue


Can't create users -- permissions issue

Author
Message
Ray K
Ray K
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26713 Visits: 5381
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/
Dev
Dev
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38388 Visits: 1604
It’s your own system so I am asking it, Are you not using sa login for running the scripts?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)

Group: General Forum Members
Points: 902288 Visits: 48714
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


Ray K
Ray K
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26713 Visits: 5381
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/
Ray K
Ray K
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26713 Visits: 5381
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/
Dev
Dev
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38388 Visits: 1604
CREATE USER [UserName] 
FOR LOGIN [UserName]
WITH DEFAULT_SCHEMA=[SchemaName]



Does the login & schema exist?
Steve Jones
Steve Jones
SSC Guru
SSC Guru (602K reputation)SSC Guru (602K reputation)SSC Guru (602K reputation)SSC Guru (602K reputation)SSC Guru (602K reputation)SSC Guru (602K reputation)SSC Guru (602K reputation)SSC Guru (602K reputation)

Group: Administrators
Points: 602256 Visits: 21100
When you rebuilt, and resinstalled, I assume, did you "add Current User" as an administrator? That's easy to miss.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Ray K
Ray K
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26713 Visits: 5381
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/
GilaMonster
GilaMonster
SSC Guru
SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)SSC Guru (902K reputation)

Group: General Forum Members
Points: 902288 Visits: 48714
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


Ninja's_RGR'us
Ninja's_RGR'us
SSC Guru
SSC Guru (262K reputation)SSC Guru (262K reputation)SSC Guru (262K reputation)SSC Guru (262K reputation)SSC Guru (262K reputation)SSC Guru (262K reputation)SSC Guru (262K reputation)SSC Guru (262K reputation)

Group: General Forum Members
Points: 262263 Visits: 9673
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 ;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search