A problem so simple I'm a little embarrassed to post it... I am setting up a trigger in which I want to, among other things, record the network ID of the user who performs the action that triggers the trigger. I know there is a variable or function out there to pull that information, but I can't find it, and have tried every variation of "login logname usr_id network_id....." I can find.
So first.... could somebody please tell me the variable or function that will return that piece of information. And second, if you also could point me to a good place, either in print or on line, to look up that kind of information, I would be most grateful.
Thanks.
Hello Leslie. The first thing to remember, there is no stupid question (well almost never )
The second thing I will point you to is the Downloadable version of the "BOL" (Books On Line).
It can be found here. http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=SQL+BOL If you are using SQL 2005 then it will be the 4th link down. You should also be able to access this by hitting F1 in your Enterprise Manager or inside of SQL Studio. Then switch over to the Index.
Then remmeber that most variables in SQL that are global either scoped to the whole server or the current connection will usually begin with a @.@.. Typing the @.@. in the index will get you in the near vicinity.
I personally found the @.@.PROCID which
Returns the object identifier (ID) of the current Transact-SQL module. A Transact-SQL module can be a stored procedure, user-defined function, or trigger. @.@.PROCID cannot be specified in CLR modules or the in-process data access provider.
and @.@.SPID
Returns the session ID of the current user process.
Try both of those and see if one of those does what you are looking for.
Hope that helps. If you have further questions feel free to ask.
|||Hi Leslie,
I think you're after the SYSTEM_USER function, which will return the windows login name in the form of ADomain\AUser (if the current user has used a trusted win connection of course).
Cheers,
Rob
No comments:
Post a Comment