| Author |
Topic |
|
honey_191
Starting Member
49 Posts |
Posted - 2008-05-14 : 12:48:26
|
| Hi,I am executing xp_logininfo .I got the resultin 5 columns.1st column contains accountname(domain\login)But i need to see login name only,not the domain.How can i do that? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-14 : 13:07:36
|
| Use CHARINDEX to find the slash, and then use SUBSTRING or RIGHT functions to get everything after the slash.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-14 : 14:00:58
|
| or use SELECT PARSENAME(REPLACE(accountname,'\','.'),1) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-14 : 14:03:10
|
| honey_191 is never going to learn if we just provide the answer. We've done enough hand holding recently.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
honey_191
Starting Member
49 Posts |
Posted - 2008-05-14 : 15:24:08
|
| No Tara,First i am going to google and search for the content,If i didn't find anything after that only iam posting.Any way.Thanks for the responses. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-05-14 : 15:26:39
|
| You missed my point. I was referring to the PARSENAME solution provided. The reason I provided hints in my first post in this thread was to help you learn.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
|
honey_191
Starting Member
49 Posts |
Posted - 2008-05-25 : 02:14:46
|
| I am getting some problem in using parsename fuction,if my login name is DOMAIN\firstname.lastname,it is displaying only the last name,but i want to display as firstname.lastname. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-25 : 10:31:28
|
quote: Originally posted by honey_191 I am getting some problem in using parsename fuction,if my login name is DOMAIN\firstname.lastname,it is displaying only the last name,but i want to display as firstname.lastname.
SELECT CASE WHEN CHARINDEX('\',accountname)>0 THEN SUBSTRING(accountname,CHARINDEX('\',accountname)+1,LEN(accountname))ELSE accountnameEND AS loginname |
 |
|
|
|