개발을 하다보면 데이터베이스를 연결하는 경우가 있습니다.
데이터베이스 파일 자체에 기존의 로그인 계정이 존재하지만, 데이터베이스 인스턴스의 로그인과 매핑이 되어야 새로 연결한 데이터베이스에 로그인 하여 사용할 수 있습니다.
SSMS로 인스턴스에 매핑할 사용자를 만들었는데
Error 15023 User or role already exists in the current database
에러 메세지를 낼때가 있습니다.
인스턴스의 계정과 기존의 데이터베이스에 있는 계정이 매핑에 실패하였을 때 발생하며, 새쿼리 창을 띄워서 아래의 명령을 실행 시키면 문제가 해결 됩니다.
exec sp_change_users_login Update_One, 'MyLogin', 'MyLogin'
솔루션 해결에 대한 블로그 포스트
Error 15023 User or role already exists in the current database
You may run into the 15023 error if you restore a MS SQL database from backup. You expect a restored database to be in exactly the same state as the backup, but the login fails for a user that had permissions in the backed up database. When you use the "User Mapping" SQL Management Studio functionality to allow the user permissions to the new database, you receive the 15023 error. This is caused by Security identification numbers (SID) that are mismatched or 'orphaned' in the sysusers table.
The SQL Server stored proc sp_change_users_login locates and fixes these records. Run it with a single parameter 'Report' to get a listing of abandoned user names and corresponding SIDs:
exec sp_change_users_login Report
The 'Update_One' parameter will reconnect a single login:
exec sp_change_users_login Update_One, 'MyLogin', 'MyLogin'
You can find more info about this issue at:
http://support.microsoft.com/kb/246133
http://support.microsoft.com/kb/240872
This next blog expands on the available parameters for sp_change_users_login:
Also, try checking out the source for sp_change_users_login found in the Sql Server Management Studio under Databases | System Databases | Master | Programmability | Stored Procedures | sp_change_users_login.
'SQL Server' 카테고리의 다른 글
| SQL Server 2005 의 새로운 기능을 이용해 !! 더 적은 코드로 더 빠르게 일할 수 있어 (0) | 2010/07/21 |
|---|---|
| [MSSQL Server 2008 SSMS] Error 15023 User or role already exists in the current database (0) | 2009/11/24 |
| MSSQL Identity 컬럼 Reset (0) | 2009/03/17 |
| SQL Sever Management Studio(SSMS) 설치 안되는 문제 - Visual Studio 2008과 관련 (0) | 2009/01/14 |
| 저장프로시저 네이밍 컨벤션 - Stored Procedure Naming Conventions (0) | 2008/02/25 |
| DataBase Naming Convention (0) | 2008/01/11 |


글 검색 결과 - 2009/11 (총 1개)



