Home > SQL Server > Get the current user session identity – SQL Server

Get the current user session identity – SQL Server


@@SPID returns the session ID of the current user process of the SQL connection. We get smallint value as a session id from this function.

SPID is a key value that administrators can use to track the activities of the users sessions in the server.

Implementation

1. Getting current user session id. You will get different id in your machine.

pic12. Get all session information using DMV “sys.dm_exec_sessions”

pic2 This DMV has lots of information. You can explorer this in you machine and find the rest of the columns that is hidden in the above image.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: