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 2000 Forums
 SQL Server Administration (2000)
 USER details

Author  Topic 

Ex
Posting Yak Master

166 Posts

Posted - 2005-01-17 : 00:41:02
hey all,

i was wondering if it is possible
i have application with sql server as the backend database
the application logs in with 1 user name and password

but i was wondering in some of my tables i want to capture the windows login name of the person using the application

is there a way to do this in sql server

for example the keyword USER will give you the login name of the account you loged in on i.e sa gives the name dbo

is there another function or way to get the windows login of the person using the database?

Hippi
Yak Posting Veteran

63 Posts

Posted - 2005-01-17 : 01:03:01
quote:
Originally posted by Ex

hey all,

i was wondering if it is possible
i have application with sql server as the backend database
the application logs in with 1 user name and password

but i was wondering in some of my tables i want to capture the windows login name of the person using the application

is there a way to do this in sql server

for example the keyword USER will give you the login name of the account you loged in on i.e sa gives the name dbo

is there another function or way to get the windows login of the person using the database?


How about Select SUSER_SNAME()
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-01-17 : 01:17:18
select user

--------------------
keeping it simple...
Go to Top of Page

Ex
Posting Yak Master

166 Posts

Posted - 2005-01-17 : 19:23:10
ok sorry might not have been specific enough

SUSER_SNAME() returns the login name

USER returns the name for the login name i.e sa is refered to as dbo


what i wanted to get was the windows NT login name

is this possible to get?
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-01-18 : 01:45:54
select nt_username from master..sysprocesses
where spid=@@spid

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -