תשובה For new Login unable to access Database

  • יום שישי 02 מרץ 2012 10:23
     
     

    As a dba i have created Login and it is able to get in to server and not able to accesss the Specific DB'S and getting below error

    messagesTITLE: Microsoft SQL Server Management Studio
    ------------------------------

    Create failed for User 'maddy'.  (Microsoft.SqlServer.Smo)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.2796.0+((KJ_SP1_QFE-CU).111209-1117+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+User&LinkId=20476

    ------------------------------
    ADDITIONAL INFORMATION:

    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

    ------------------------------

    User, group, or role 'Maddy' already exists in the current database. (Microsoft SQL Server, Error: 15023)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.2796&EvtSrc=MSSQLServer&EvtID=15023&LinkId=20476

    ------------------------------
    BUTTONS:

    OK
    ------------------------------

כל התגובות

  • יום שישי 02 מרץ 2012 10:48
     
     תשובה

    Hallo Maddy,

    make sure that no other "user name" exists in the database with the name maddy.
    You can check orphaned users by using the following script:

    USE [database]
    GO

    EXEC sp_change_users_login 'report'

    To understand the differences between login and users of a database see
    http://msdn.microsoft.com/en-us/library/bb510418.aspx

    To get detailled information concerning sp_change_users_login see:
    http://msdn.microsoft.com/en-us/library/ms174378.aspx


    Uwe Ricken

    MCITP Database Administrator 2005
    MCITP Database Administrator 2008
    MCITP Microsoft SQL Server 2008, Database Development

    db Berater GmbH
    http://www-db-berater.de

    • סומן כתשובה על-ידי Iric WenModerator יום שני 12 מרץ 2012 09:19
    •  
  • יום שישי 02 מרץ 2012 11:01
     
     

    Ricken,

    i excuted EXEC sp_change_users_login 'report' on server and i dont maddy as orphan user and there is no other user name is like Maddy, what should i do next

  • שבת 03 מרץ 2012 21:34
     
     

    Maddy,

    please take care that you run the sp in the database where you want to add the user!
    I suppose that you did run the proc in the master database.


    Uwe Ricken

    MCITP Database Administrator 2005
    MCITP Database Administrator 2008
    MCITP Microsoft SQL Server 2008, Database Development

    db Berater GmbH
    http://www-db-berater.de

  • יום ראשון 04 מרץ 2012 09:58
    מנחה דיון
     
      קוד כלול

    Hi,

    Please make sure whether that user exists in the database or not, you can run the following query:

    USE <db_name>;
    GO
    SELECT name, type_desc
    FROM sys.database_principals;
    GO


    Alex Feng | SQL Server DBA, ALIBABA.COM
    My Blog | MCTS: SQL Server 2008, Implementation and Maintenance
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • יום ראשון 04 מרץ 2012 17:01
     
     

    Hi Alex,

    just as an information - your solution will not work because user names can be totaly different from the login name.
    Your query will not really give the requestor the needed information. You need to join the database_principals with server_principals.
    Therefore the best would be using sp_change_users_login!

    In general only the SId is the identifier between server_principal and database_principal.

    security: http://msdn.microsoft.com/en-us/library/ms181127.aspx
    server_principals: http://msdn.microsoft.com/en-us/library/ms188786.aspx
    database_principals: http://msdn.microsoft.com/en-us/library/ms187328.aspx


    Uwe Ricken

    MCITP Database Administrator 2005
    MCITP Database Administrator 2008
    MCITP Microsoft SQL Server 2008, Database Development

    db Berater GmbH
    http://www-db-berater.de

  • יום שני 05 מרץ 2012 06:47
    מנחה דיון
     
     תשובה

    Hi Maddy,

    An add-in to Uwe, you can refer to this blog to troubleshoot your issue:

    SQL SERVER – FIX : Error 15023: User already exists in current database

    http://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/


    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • סומן כתשובה על-ידי Iric WenModerator יום שני 12 מרץ 2012 09:19
    •