SQL Server Management Studio (SSMS) is nice tool, but there are instances where it will mislead you. This is one of them I found.
Every DBA knows that @@SPID will returns the session ID of the current user process.
You can view the SPID by running following query.
SELECT @@SPID
Apart from this you can use the SSMS to view the SPID as well. If you look down the tool bar of the query window of the SSMS as shown below.
Now, theoretically @@SPID and above value should be same, which you can see from image below
Let me restart the SQL Server instance and let us check what will happen to the above query now.
Now then, it is a contradiction. Obviously, @@SPID cannot be wrong and it is the SSMS the culprit, where SSMS won’t refresh.
So the conclusion, don’t trust SSMS too much.
Good catch.
ReplyDeleteSenthu Sritharan commented on facebook
ReplyDeleteMy co-DBA recently connected to prod then right clicked and changed to a test server. SSMS showed as test server in the below pane. But firing @@SERVERNAME showed that it hasn't changed from production. :-) "