Link to home
Start Free TrialLog in
Avatar of aparfitt
aparfittFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Server equivalent to Access's Environ("Username")

I have tried SUSER_SNAME and System_user but they return the domain name as well as the user name.

Does anyone know how to get just the user name?

Thanks.
Avatar of YZlat
YZlat
Flag of United States of America image

try using Replace function or Left and Right functions to get just the domain name
ASKER CERTIFIED SOLUTION
Avatar of i2mental
i2mental
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
actually here:
SELECT PARSENAME(REPLACE(SUSER_SNAME(),'\','.'),1)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial