MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 17th, 2004, 03:42 PM
jammy123 jammy123 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 jammy123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Problem adding SQL users to database.

Hello...

Can anybody help me with the following problem I'm experiencing with MS SQL server 2000.

I recently attached an old database to my new server using the script :
EXEC sp_attach_db @dbname = N'requisite',
@filename1 = N'W:\database\data\reqel.mdf',
@filename2 = N'W:\database\data\reqel.ldf'

However during this process no login name was created for the database user(s). I tried creating this user but kept getting the following error:

error 21002: [SQL-DEMO]User ' reqel' already exists.

I can't delete the existing database user because this user is the owner of several database tables.

Does anyone know how I can resolve this issue???

Thanks in advance
Jammy

Reply With Quote
  #2  
Old February 17th, 2004, 04:56 PM
jammy123 jammy123 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 jammy123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

Hallo everyone,

I have found the solution to this problem. So for those of you who might be experiencing the same problem. Here is the solution:

Steps To Resolve Orphaned Users
Run the following command for the orphaned user from the preceding step: Use Northwind
go
sp_change_users_login 'update_one', 'test', 'test'

This relinks the server login "test" with the the Northwind database user "test". The sp_change_users_login stored procedure can also perform an update of all orphaned users with the "auto_fix" parameter but this is not recommended because SQL Server attempts to match logins and users by name. For most cases this works; however, if the wrong login is associated with a user, a user may have incorrect permissions.
After you run the code in the preceding step, the user can access the database. The user may then alter the password with the sp_password stored procedure: Use master
go
sp_password NULL, 'ok', 'test'

This stored procedure cannot be used for Microsoft Windows NT security accounts. Users connecting to a SQL Server server through their Windows NT network account are authenticated by Windows NT; therefore, their passwords can only be changed in Windows NT.

Only members of the sysadmin role can change the password for another user's login.

Reply With Quote
  #3  
Old March 11th, 2004, 01:08 AM
agentfoxmulder agentfoxmulder is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 agentfoxmulder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Thanks!!!

YOU are the man!

I'm helping someone else out with some SQL Server 2000 stuff and got stuck on the Error 21002. I did a google and came across your posting and solution. Your solution did the trick and I was able to appreciate.

FWIW, thank you very much! Guess the truth is out there...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Problem adding SQL users to database.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway