QOD 7/29/2003

  • Hi there,

    I guess it was too early to answer today's QOD

    I choose USER instead of SYSTEM_USER.

    From BOL

    SYSTEM_USER

    Allows a system-supplied value for the current system username to be inserted into a table when no default value is specified.

    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.

    Is this the only difference?

    Cheers,

    Frank

    In the subject you can see, that it's still too early

    Edited by - a5xo3z1 on 07/29/2003 01:21:58 AM

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • One would expect a more reponsible approach to QOD from you Frank.

    As an experienced DBA you must try to follow standard procedure in your morning activities:

    1. coffee

    2. another coffee

    3. QOD

    Here Down Under we don't see QOD until the afternoon, so I guess I'm all caffeined up and at a distinct advantage.

    Cheers,

    - Mark


    Cheers,
    - Mark

  • quote:


    One would expect a more reponsible approach to QOD from you Frank.

    As an experienced DBA you must try to follow standard procedure in your morning activities:

    1. coffee

    2. another coffee

    3. QOD


    1. coffee ok ...

    2. another coffee missed this one. Sh*t

    3. QOD I'm a loser, baby

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • If you sign in through QA and try both, you'll see the difference even though BOL is not very clear. If you signin with bknight into your server, and use SYSTEM_USER, it will say bknight. USER will say dbo.

    Brian Knight

    bknight@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/bknight

  • Hi Brian,

    quote:


    If you sign in through QA and try both, you'll see the difference even though BOL is not very clear. If you signin with bknight into your server, and use SYSTEM_USER, it will say bknight. USER will say dbo.


    it was definitely too early.

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Why not session_user ?

  • quote:


    Why not session_user ?


    Because session_user returns the database user name, not the login name.

  • May I know the difference between database user name and log in name? I know the log in name is "sa" or "bknight", but who is "dbo"? Is it something like a user group?

    Thanks,

    Karen.

  • dbo is DataBase Owner. Anyone can be assigned the dbo privilege/permission.

    Use Enterprise Manager, drill down to Security. Expand that and select Logins. Right click on a login and select Properties. Go to the Database Access tab and select a database. Look at the list of Roles for the database. You will see db_owner. That's DBO.

    -SQLBill

  • Ok, I missed this one too because it was too early and I was in a rush. I'm wondering, though, what's the difference between SYSTEM_USER and SUSER_SNAME()?

    Jason

  • I don't think there's any difference. SUSER_SNAME() can be used instead. However, SYSTEM_USER is the more accepted, and might even be something that will work across other database systems.

    I think SYSTEM_USER will give consistent results across all SQL versions too.

    Cheers,

    - Mark


    Cheers,
    - Mark

  • I have used both User_name() and also System_User in different instances. Both functions return the same results for a SQL user account as long as it is mapped same. However, for NT accounts the results may be different. For example an NT account with Sysadmin prevs and also assigned to db_owner database role, the system_user returns NT login (Domain\User) but user_name or user() returns dbo. By definition,

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

    SYSTEM_USER: Allows a system-supplied value for the current system username to be inserted into a table when no default value is specified

    Well the choice of function depends on what one is trying to achieve ? read a login or database user name.

    Have a good one

    -Sravan

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply