How to Query NT network to find user id

greenspun.com : LUSENET : SQL Server Database Administration : One Thread

Hi guys,

I am wondering if you know how to do something?

The application I am working on is connecting to the a SQL Server 6.5 database using the NT trusted connection. I have to input User Names into some table columns for update stamps. All the SQL Server functions I have found need at least one parameter to get an answer ie: user id to get user name etc.

One stored procedure(sp_who) requires a 'spid' which is a specific process. I am not sure whether this is an operating system process or a SQL Server process.

Does anyone know how I can query the NT network the application is running on to get the user name or user id or process id???. the front end is VB and my users do not want to log on to the application.

Thank you,

Paul Tribe

-- Anonymous, February 11, 1999

Answers

Hi Paul,

It's me Eric. I am the one around here who answers the questions. Everybody else asks them.

Anyway, use: select * from sysprocesses where spid = @@spid

(or just select the nt_username column) to get the information about who you are.

Eric

-- Anonymous, February 11, 1999


Moderation questions? read the FAQ