DBA Diaries

Thoughts and experiences of a DBA working with SQL Server and MySQL

Home All Articles Using DBCC INPUTBUFFER for SQL Server troubleshooting

Using DBCC INPUTBUFFER for SQL Server troubleshooting

Posted on May 27, 2012 Written by Andy Hayes Leave a Comment

dba toolboxIn my last post on sp_who2 I demonstrated how this handy utility can help you in your SQL Server troubleshooting efforts.

Continuing on from this, I am going to cover DBCC INPUTBUFFER

What is DBCC INPUTBUFFER ?

It is a command used to identify the last statement executed by a particular SPID. You would typically use this after running sp_who2. The great thing about this DBCC command is that it shows the last statement executed, whether running or finished.

How to use

DBCC INPUT BUFFER will generate errors so ensure that the space between INPUT and BUFFER is omitted.

In this example, I have just run run sp_who2 and identified that my lead blocker is SPID number 54 so I would run as follows:

T-SQL:

DBCC INPUTBUFFER(54)

Here is a simple demonstration. In a new query window run this

BEGIN
UPDATE Orders SET Amount = 500 WHERE OrderID = 1;

Now in a second query window run this

UPDATE Orders SET Amount = 200 WHERE OrderID = 1;

Now run sp_who2 to identify the lead blocker followed by DBCC INPUTBUFFER using the lead blocker SPID. Here are my results with the column “EventInfo” providing the detail that I need on the T-SQL which is causing the problem. It is possible to copy and paste the code into a query window for analysis.

using dbcc inputbuffer for sql server troublshooting

Permissions needed for DBCC INPUTBUFFER

You need to be a sysadmin or have the VIEW SERVER STATE permission to be able to run this command.

Conclusion

Again, like sp_who2, this handy command should be in your “DBA Toolbox”.

UJNZMQQN5JCV

Related Posts:

  • How to Setup MySQL Master Master ReplicationHow to Setup MySQL Master Master Replication

Filed Under: All Articles, SQL Server Administration Tagged With: dbcc, sql server, troubleshooting

About Andy Hayes

Andy Hayes is a DBA working with SQL Server since version 7.0. He has a wonderful wife and two beautiful children. He loves database technology, playing cricket, and blogging. He is passionate about sharing his experiences as a DBA and learning more to further his understanding and knowledge. You can follow me on Twitter, check out my Facebook page or follow me on Google+

Leave a Reply Cancel reply

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

CAPTCHA
Refresh

*

Categories

  • All Articles (82)
  • Career Development (8)
  • MySQL Administration (18)
  • MySQL Performance (2)
  • SQL Server Administration (24)
  • SQL Server News (3)
  • SQL Server Performance (14)
  • SQL Server Security (3)
  • SQL Tips and Tricks (19)

Top 10 Popular Posts

  • Using sp_change_users_login to fix SQL Server orphaned users
  • How to shrink tempdb
  • MySQL SHOW USERS? – How to List All MySQL Users and Privileges
  • How to Transfer Logins to Another SQL Server or Instance
  • How to Delete Millions of Rows using T-SQL with Reduced Impact
  • T-SQL – How to Select Top N Rows for Each Group Using ROW_NUMBER()
  • New T-SQL features in SQL Server 2012 – OFFSET and FETCH
  • How to Kill All MySQL Processes For a Specific User
  • Using exec sp_who2 to help with SQL Server troubleshooting
  • How to move tempdb

Recent Posts

  • How to Setup MySQL Master Master Replication
  • How To Use SQL to Convert a STRING to an INT
  • How to set up MySQL Replication Tutorial
  • How to Use SQL CASE for Conditional Logic in Your SQL Queries
  • Using ISNULL in SQL Server to Replace NULL Values

Search

Connect

  • Twitter
  • Facebook
  • Google+
  • RSS

About

  • Cookie Policy
  • Disclaimer
  • About
Copyright © ‘2021’ DBA Diaries built on the Genesis Framework

This site uses cookies. We assume you are happy with cookies but click the link if you are not. Close