Translate

Saturday, March 12, 2011

Another reason why you should not trust UIs

 

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.

image

Now, theoretically @@SPID and above value should be same, which you can see from image below

image

Let me restart the SQL Server instance and let us check what will happen to the above query now.

image

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.

2 comments:

  1. Senthu Sritharan commented on facebook

    My 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. :-) "

    ReplyDelete