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

    Regards,
    Shivi
  2. Kewin New Member

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

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

    Remarks
    USER provides the same functionality as the USER_NAME system function.

    USER_NAME
    Returns a user database username from a given identification number.

    SUSER_SNAME
    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.

    /Kenneth
  3. shivi New Member

    Kenneth,

    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 ..

    Regards,
    Shivi
  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?

    /Kenneth

Share This Page