Navigation

Search

Categories

On this page

Get the current username and domain for the currently authenticated SQL Server user for Windows Integrated Authentication

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Monday, September 28, 2009
Monday, September 28, 2009 1:58:31 PM (Mountain Daylight Time, UTC-06:00) ( )

The title of this post declares the intent of the code below

DECLARE @Domain VARCHAR(50);
DECLARE @Account VARCHAR(50);
SET @Domain = SUBSTRING(SYSTEM_USER, 0, CHARINDEX('\', SYSTEM_USER));
SET @Account = SUBSTRING(SYSTEM_USER, CHARINDEX('\', SYSTEM_USER) + 1, LEN(SYSTEM_USER) - CHARINDEX('\', SYSTEM_USER));
SELECT @Domain + '\' +@Account AS samAccountName;

Comments [0] | | #