Wednesday, December 16, 2015

Sp_who, Sp_who2


In order to troubleshoot performance problems or slowness we use the above stored procs.  Blocking, High I/O, High CPU and queries running parallelism can be seen in most cases. The First 50 results i.e results with SPID’s 1 to 49 represent system events and generally will not cause system slowdown. Users sessions are 50 and above. Multiple rows having the same SPID or SessionID are parallel processes.  The Blkby column is used to find out if any sessions are being blocked.


Sp_who: Provides information about current users, sessions, and processes in an instance of the Microsoft SQL Server Database Engine. When used with option active it gives the filtered information of those processes that are not idle.When used with userid  or sessionid the information retrieved belong to a specific user, or that belong to a specific session.

Syntax: Exec Sp_who


SP_who2: Is undocumented hence not supported by Microsoft but widely used as Sp_who2 provides extra columns compared to sp_who. Sp_who2 output results are same as sp_who with some extra columns and can be used to get more information about session id's.

Syntax: Exec Sp_who2



Friday, December 11, 2015

Common SQL Interview questions



  1. What is Database?
  2. Define primary key, foreign key and unique key?
  3. Difference between clustered index and non clustered index?
  4. What are the files associated with a database in SQL server?
  5. What is normalization?
  6. What is a join and what types of joins in SQL Server?
  7. What are constraints in SQL Server?
  8. What is a view? How to update a view in SQL Server?
  9. Difference between Union and Union ALL?
  10. Difference between Stored procedure and function?
  11. Difference between truncate and delete?
  12. What is a linked server?
  13. What is difference between clustered index and non clustered index?
  14. What is cursor and what are alternatives to cursor in sql server?
  15. What are DBCC commands?
  16. What is a trigger and types of triggers in SQL server?
  17. What are isolation levels in SQL server?
  18. What is SQL profiler why is it used?
  19. What is Activity monitor why is it used?
  20. What is SQL server agent?
  21. What is SQL Server Browser?
  22. What are ACID properties in a database?
  23. What are DMV’s ?
  24. What are the types of Backups in SQL server?
  25. What is log shipping and why is it used?