Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Stored procedure

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 Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-14 : 14:00:58
or use SELECT PARSENAME(REPLACE(accountname,'\','.'),1)
Go to Top of Page

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 Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

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.
Go to Top of Page

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 Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

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.
Go to Top of Page

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 accountname
END AS loginname

Go to Top of Page
   

- Advertisement -