Does lastBatch in sp_who2 really mean the time the user execute a SQL batch

  • I usually use sp_who2 see who is connected and is active in the SQL server database.

    When executing sp_who2, there is a column lastbatch, when each time I executed sp_who2, I see the time is updated almost the current time, may be a couple of minutes earlier, but I see those processes are in sleeping status . awaiting command.

    Does that mean those users execute last batch of SQL a  couple of minutes ago?

    Could that be possible they  just logged in many hours ago and did not log out ?

    I know I can use sp_whoisActive, but I see no active ones in the result.

    Thanks

  • This comes from sys.sysprocesses. If you check the docs (https://docs.microsoft.com/en-us/sql/relational-databases/system-compatibility-views/sys-sysprocesses-transact-sql?view=sql-server-ver15), this is listed as the last time that the user executed something.

  • Thank you, yes,  I get to know sysprosses result the same as sp_who2.

    But if I run sp_whoIsActive, I click during the lastbatch time, but no records shows.

    So I am wondering if those users are only connect to the database, or left desk and leave the connection open without doing anything.

    Thanks

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

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