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
 Transact-SQL (2005)
 Return user name without login

Author  Topic 

cidr
Posting Yak Master

207 Posts

Posted - 2009-04-29 : 09:28:08
Hi there,

I wonder if anyone knows how to return the username without returning the server part.

For example, if I use (suser_sname()) or SYSTEM_USER. I get back Server/username. So in my case that's ACTCO/pwatson.

I want to strip the ACTO/ part and have only pwatson. I've tried RTRIM and CHARINDEX etc, but can't find a way to strip the first 6 characters to resolve this.

Hope someone can help.

Thaks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-04-29 : 09:36:49
As an approach:
select replace('ACTCO/pwatson','ACTCO/','') or

select replace((select system_user),(@@servername+'/'),'')

Webfred



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-30 : 04:09:53
or

select substring(suser_sname(),charindex('/',suser_sname())+1,len(suser_sname()))

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -