Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 can't create sql user
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Flowing Fount of Yak Knowledge

1410 Posts

Posted - 12/28/2012 :  04:44:38  Show Profile  Reply with Quote
I'm moving a database to a new server

I tried to script the logins but they are not working

I see the users and modified the passwords but i'm getting an error

[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'xuser'.

any advise
I tried to drop and recreate but when I try dropping in the database itself I get an error

DROP USER [xuser]
Msg 15138, Level 16, State 1, Line 2
The database principal owns a schema in the database, and cannot be dropped.

I moved the database and then the users
should I do the opposite - delete the datbase and then move users and then database?

Flowing Fount of Yak Knowledge

7174 Posts

Posted - 12/28/2012 :  09:22:56  Show Profile  Reply with Quote
You don't need to drop database. After you migrate DB,you can either create logins with same username and password and map the logins or if you are doing for muliple dbs and logins then i would suggest you to search for "Transfer logins from one server to other server" kb article
Go to Top of Page

Constraint Violating Yak Guru

352 Posts

Posted - 12/28/2012 :  09:27:43  Show Profile  Reply with Quote
Also look up orphaned users.
Here is the first topic that came up for me

Go to Top of Page

Flowing Fount of Yak Knowledge

1410 Posts

Posted - 12/29/2012 :  11:59:44  Show Profile  Reply with Quote
this didn't do the trick

dropping the database didn't work either
I would like to delete from both and start again but it doesn't let me drop the user from the database (that was restored from the backup) what else can I do?
Go to Top of Page

Aged Yak Warrior

819 Posts

Posted - 12/30/2012 :  10:24:54  Show Profile  Reply with Quote
To migrate logins - lookup sp_help_revlogin and install that on the source system. Use that procedure to generate the script to create the logins on the destination.

This script will create the logins with the appropriate SID, which will then map to the users in the database correctly and also creates the logins with the same password as on the source system.
Go to Top of Page

Flowing Fount of Yak Knowledge

1410 Posts

Posted - 12/30/2012 :  13:42:56  Show Profile  Reply with Quote
thanks the actual problem wasn't with the logins at all - - I didn't have sql authentication checked on the new server
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000