SQL Server Performance

"select user" query

Discussion in 'General DBA Questions' started by shivi, Feb 14, 2007.

  1. shivi New Member

    When using the query select user , in one sql server it gives the 'user name' and in another it gives 'dbo' for the same user with same permissions.

    I know that to get the user name we need to use the function suser_sname().

    But I want to know why select user is giving different results though the user permissions are the same in both servers for this user.

    Please let me know

  2. Kewin New Member

    Are you sure that it's the same permissions, membership in roles etc on both servers?

    --- brief BOL snip ---
    Allows a system-supplied value for the current user's database username to be inserted into a table when no default value is specified.

    USER provides the same functionality as the USER_NAME system function.

    Returns a user database username from a given identification number.

    Returns the login identification name from a user's security identification number (SID).
    --- ned BOL ---

    These different functions are very similarly named, but sometimes works differently.
    BOL has more indepth info on this.

  3. shivi New Member


    Yes I checked the permissions again for this user (windows authentication) and he is the dbo of the database in both servers.

    Also , Now I added another user (windows authentication) with just the default public database role to the same database in both sql servers.

    In one sql server the same query gives dbo and in another it gives the full user name ..

  4. Kewin New Member

    ..seems strange..
    Something has to be different between the two..
    Are the SQL servers of the exact same version?
    OS on the servers?
    In the same domain?


Share This Page