SQL SERVER – System Stored Procedures I Use to Get Started

System Stored Procedures remain part of my troubleshooting toolbox. I use these familiar entry points before moving to more detailed views.

Different inspection tools share a fitted toolbox, each suited to a distinct task.

My working style has changed over the years, but these small entry points remain useful. The table keeps the original seven procedures and clarifies what their output can tell you.

ProcedureUseful starting point
sp_whoSessions and current activity, including blocking session identifiers.
sp_lockLegacy lock details, not a captured deadlock graph.
sp_spaceusedDatabase or table space usage.
sp_helpdbDatabase properties and file information.
sp_monitorInstance activity statistics since the previous invocation.
sp_helpindexBasic index descriptions for a table.
sp_statisticsIndex and statistics information exposed through the ODBC-oriented procedure.
EXEC sys.sp_who;
EXEC sys.sp_spaceused;
EXEC sys.sp_helpdb;
-- In the database containing the table:
-- EXEC sys.sp_helpindex N'dbo.YourTable';
-- EXEC sys.sp_statistics @table_name = N'YourTable', @table_owner = N'dbo';

I avoid treating this list as a complete performance diagnosis. For current lock investigation, sys.dm_tran_locks provides more detail than the deprecated sp_lock procedure. Blocking information is not the same as a deadlock graph, which records the participants and resources in a completed cycle. Permissions and the database context affect what you can see.

Which system procedure do you still reach for first? Community procedures are useful too, but they were outside the scope of this original list.

Reference: Legacy sp_lock and its replacement.

A familiar procedure is not a complete diagnosis, it is an entry point into the evidence.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Scripts, SQL Server, SQL Stored Procedure
Previous Post
SQL SERVER Installation – FeatureUpgradeMatrixCheck (SQL Server 2016 Feature Upgrade) setup rule failed
Next Post
SQL SERVER – Becoming a More Effective DAX Developer with DAX Studio – Notes from the Field #134

Related Posts

6 Comments. Leave new

  • As Microsoft is warning people against using sp_lock, I wrote the following query which helps show currently executing queries – and where available, information about the blocking query.

    SELECT
    ES.login_name as [user],
    er.session_id as [session_id],
    BES.login_name as [blocking_username],
    er.blocking_session_id as [blocking_session_id],
    er.percent_complete,
    BES.status as [blocking_status],
    db_name(BES.database_id) as [blocking_db],
    er.start_time,
    datediff(SS, start_time, getdate()) as [run time],
    er.status,
    er.command,
    er.database_id,
    db_name(er.database_id) as [database], text,
    query_plan,
    query_plan.query(‘declare namespace MSBS=”http://schemas.microsoft.com/sqlserver/2004/07/showplan”; //MSBS:ParameterList/*’) as xquery,
    BES.host_name as [blocking_host],
    BES.host_process_id as [blocking_host_pid]
    FROM
    sys.dm_exec_requests er
    CROSS APPLY sys.dm_exec_sql_text(sql_handle)
    cross apply sys.dm_exec_query_plan(plan_handle) as qp
    LEFT JOIN sys.dm_exec_sessions BES ON er.blocking_session_id = BES.session_id
    LEFT JOIN sys.dm_exec_sessions ES ON er.session_id = ES.session_id
    WHERE er.session_id @@SPID

    Reply
  • That’s quite intersesting. By the way, thank you SO MUCH, Pinale Dave, for sharing your knowledge and your experience, this is priceless, and it’s always a pleasur to read your blog. Good job, dude ! :)

    Reply
  • Thanks for sharing,

    Reply
  • using the helpindex procedure I have found that I have multiple indexes (up to 3) on a table that all seem to be structured around the same columns but the indexes have differing names
    Is this the norm for indexes?
    thanks

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.