Solved

'user_name()' funtion  returns domain as well

Posted on 2003-11-21
3
316 Views
Last Modified: 2012-08-14
I have set of logins and users for a database who all inherit permissions from a Windows group.

When a user takes a record, a field called '[UName]' is populated.  I have set the default value of this field to the function  'user_name()' to get the value into the field.

I do not want any of the logins, database access permissions of their own as they automatically inherit from the Windows Group.  However if I take all db permissions away and rely on the group permissions, 'user_name()' returns 'mydomain/harry' instead of just 'harry'.

I would like to return just the username without the domain.  Is there another command that will do this for me or will I have to resort to string manipulation?

Wing
0
Comment
Question by:WingYip
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
Joeharvey earned 50 total points
ID: 9796420
user_name() gets the information straight from the SYSUSERS table.  If the account is an NT authenticated account, it will always have the domain prefix on it.  You will need to modify the string yourself.

jm
0
 
LVL 34

Expert Comment

by:arbert
ID: 9797126
Also, take a look at User_Name() or system_user
0
 
LVL 1

Author Comment

by:WingYip
ID: 9798558
Thanks all

Wing
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question