Mapping spid to windows login to user query

  • Hello,

    Here is my scenario:

    Our clients access their database via IIS with their windows account. When their session is established, their login shows up as a SQL login we assigned to the database. The dillema I have is when I am trying to troubleshoot a runaway query. Since all the clients come into SQL with the SQL login instead of their Windows login, it is near impossible to narrow down whose query it is. My question is, is there a way to map a spid to the windows login and then to the actual T-SQL language. This would allow me to analyze the query and educate the user if it is inefficient. Feedback would be greatly appreciated.

  • Depending on how/where you build your connection string, add some additional information to it so you can easily identify the spid. Add the IP address to the hostname or tweak the program name.

    Another way is once you open the connection, immediately do an insert into a table to stored spid and the real userid, then you can just join to it to filter what you need.

    Cant remove the name at the moment, but there is also a way to associate some additional data with the spid using TSQL.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply