session id

how can i find out the current session id of the SSMS window I  have open?

Each new window is a diff session id?

If I have
SELECT GETDATE()
GO
SELECT GETDATE()

Will it the same session id for both select statements?

Thanks
LVL 6
anushahannaAsked:
Who is Participating?
 
chapmandewConnect With a Mentor Commented:
each window is a new connection, which is a new session (new session id)
0
 
anushahannaAuthor Commented:
OK.

Like we have sys.sysprocesses for process id, what is the system view for session id?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
anushahannaAuthor Commented:
so session id is same as process id?
0
 
Anil GolamariConnect With a Mentor Commented:
There is not really any connection between the SPID and the connection
string, not more than between a car and a petrol station. The connection
string only specifies you connect to SQL Server.

However, an instance of a connection object in ASP .Net maps to a spid in
SQL Server. If you open Task Manager in Windows, you will see a number of
processes that all have a PID (process id). Spids in SQL Server are
locigally the same: process ids, but within SQL Server.
0
 
anushahannaAuthor Commented:
Thanks for the analogy.
0
All Courses

From novice to tech pro — start learning today.